uot;page"=pg,
"length"=len)
}
# roll up the list to a data frame. Many ways to do this.
myDF <- do.call("rbind",myList)
#
Hope that helps.
Tim
--
Date: Thu, 4 Jan 2024 12:59:59 +
From: Andy
To: r-help@r-pro
Hi folks
Thanks for your help and suggestions - very much appreciated.
I now have some working code, using this file I uploaded for public
access:
https://docs.google.com/document/d/1QwuaWZk6tYlWQXJ3WLczxC8Cda6zVERk/edit?usp=sharing&ouid=103065135255080058813&rtpof=true&sd=true
The small c
If you do something like this
for i in $(pandoc --list-output-formats);
do pandoc -f docx -t $i -o test.$i Now\ they\ want\ us\ to\
charge\
our\ electric\ cars\ from\ litter\ bins.docx;
done
you get approximately 65 formats, from which you can pick one wh
В Sat, 30 Dec 2023 12:18:52 +
Andy пишет:
> filepath <- setwd(tk_choose.dir())
Since you're using tcltk, you can get a file path in one step using
tk_choose.files(). (Use multi = FALSE to choose only one file.)
> full_filename <- paste(filepath, filename, sep="/")
There's also file.path(),
Sorry, I was being too quick.
You have to pay attention to the pipe operator
You were advised to do the following
content <- read_docx(full_filename) |>
docx_summary()
which should have worked but I think you left out the |> operator.
Alternatively
tmp <- read_docx(full_filename)
content <
An update: Running this block of code:
# Load libraries
library(tcltk)
library(tidyverse)
library(officer)
filepath <- setwd(tk_choose.dir())
filename <- "Now they want us to charge our electric cars from litter
bins.docx"
#full_filename <- paste0(filepath, filename)
full_filename <- paste(fil
docx_summary(content)
You should read documentation e.g. ?docx_summary and check the examples
section
On Sat, Dec 30, 2023 at 2:12 PM Andy wrote:
> Hi Eric
>
> Thanks for that. That seems to fix one problem (the lack of a separator),
> but introduces a new one when I complete the function Calum
Hi Eric
Thanks for that. That seems to fix one problem (the lack of a
separator), but introduces a new one when I complete the function Calum
proposed:Error in docx_summary() : argument "x" is missing, with no default
The whole code so far looks like this:
# Load libraries
library(tcltk)
libr
full_filename <- paste(filepath, filename,sep="/")
On Sat, Dec 30, 2023 at 1:45 PM Andy wrote:
> Thanks Ivan and Calum
>
> I continue to appreciate your support.
>
> Calum, I entered the code snippet you provided, and it returns 'file
> missing'. Looking at this, while the object 'full_filename'
Good idea, El - thanks.
The link is
https://docs.google.com/document/d/1QwuaWZk6tYlWQXJ3WLczxC8Cda6zVERk/edit?usp=sharing&ouid=103065135255080058813&rtpof=true&sd=true
This is helpful.
From the article, which is typical of Lexis+ output, I want to extract
the following fields and append to a
Thanks Ivan and Calum
I continue to appreciate your support.
Calum, I entered the code snippet you provided, and it returns 'file
missing'. Looking at this, while the object 'full_filename' exists, what
is happening is that the path from getwd() is being appended to the
title of the article, b
Andy,
you can always open a public Dropbox or Google folder and post the link.
el
On 29/12/2023 22:37, Andy wrote:
> Thanks - I'll have a look at these options too.
>
> I'm happy to send over a sample document, but wasn't aware if
> attachments are allowed. The documents come Lexis+, so require
help(read_docx) says that the function only imports one docx file. In
> order to read multiple files, use a for loop or the lapply function.
>
I told you people will suggest better ways to loop!!
>
> docx_summary(read_docx("Now they want us to charge our electric cars
> from litter bins.docx"))
В Fri, 29 Dec 2023 20:17:41 +
Andy пишет:
> doc_in <- read_docx(files)
>
> Results in this error:Error in filetype %in% c("docx") &&
> grepl("^([fh]ttp)", file) :'length = 9' in coercion to 'logical(1)'
help(read_docx) says that the function only imports one docx file. In
order to read mul
Thanks - I'll have a look at these options too.
I'm happy to send over a sample document, but wasn't aware if
attachments are allowed. The documents come Lexis+, so require user
credentials to log in, but I could upload the file somewhere if that
would help? Any ideas for a good location to do
I would also look at https://pandoc.org perhaps which can
export a number of formats...
And for spreadsheets https://github.com/jqnatividad/qsv is my
goto weapon. Can also read and write XLSX and others.
A sample document or two would always be helpful...
el
On 29/12/2023 21:01, CALUM POLWART
Hi Roy (& others)
Many thanks for the advice - well taken. Thanks also to the others who
have responded so quickly - I thought I might have to wait days!! :-)
I'm on a Linux (Mint) machine. Below, I document three attempts, two
using officer and the last now using textreadr
My attempts so far
It sounded like he looked at officeR but I would agree
content <- officer::docx_summary("filename.docx")
Would get the text content into an object called content.
That object is a data.frame so you can then manipulate it. To be more
specific, we might need an example of the DF
You can loop thi
textreadr would be the obvious approach.
When you say it is depreciated do you mean it's not available on cran?
Sometimes maintaining a package on cran in just a pain in the ass.
devtools::install_github("trinker/textreadr")
Should let you install it.
In theory docx files are actually just zip
checkout the 'officer' package
Thanks
Jim Holtman
*Data Munger Guru*
*What is the problem that you are trying to solve?Tell me what you want to
do, not how you want to do it.*
On Fri, Dec 29, 2023 at 10:14 AM Andy wrote:
> Hello
>
> I am trying to work through a problem, but feel like I've
Hi Andy:
I don’t have an answer but I do have what I hope is some friendly advice.
Generally the more information you can provide, the more likely you will get
help that is useful. In your case you say that you tried several packages and
they didn’t do what you wanted. Providing that code,
Hello
I am trying to work through a problem, but feel like I've gone down a
rabbit hole. I'd very much appreciate any help.
The task: I have several directories of multiple (some directories, up
to 2,500+) *.docx files (newspaper articles downloaded from Lexis+) that
I want to iterate throug
22 matches
Mail list logo