1 year ago
#43717
Ellie Ana
readtext returns error when reading too many .rtf files
I am trying to use readtext in R to import over 13,000 .rtf files but received an error message below.
uk <- readtext("/Users/path/*.rtf",
docvarsfrom = "filenames",
docvarnames = c("country", "year", "id"),
dvsep = "_")
Error in chartr(.cptable[[cpname]]$before, .cptable[[cpname]]$after, out[parsed$toconv]) :
invalid input '' in 'utf8towcs'
When I applied the same code to a test folder containing only 1,000 files, the code seemed to work fine. However, when I tried to increase the number of files in the folder to 5,000, the same error code returned. The filenames that I'm trying to import are formatted as uk_1992_1.rtf or uk_2010_3568.rtf, as shown in the link below.
My questions are:
Is this just a matter of trying to import too many files at once?
Is there a way to fix this code to allow more files to be imported at once?
Is there a workaround if there is no way to fix the code?
Apologies if the question has been asked elsewhere, I have tried to look for a similar question but did not find any. I can (and have tried to) split the files into several smaller folders, which seems to work fine, but there are more countries with the same number of files that will need to be processed and analysed the same way. TIA!
r
read-text
r
read-text
0 Answers
Your Answer