file=("LUSDR/letter.doc")
Howdy Y'all,
So i am looking to read a word document in the following formats(.doc) or
any type of accessible word processor software (e.g. text .txt, notepad,
etc). Had the ability to search certain words, for instance "banana",
"peacock","Weapons" "Mass"
"Destruction". Then i could summarize and view
the results. i looked and the only thing i could find was the below where i
want to analyze "letter.doc" and look for the words mentioned in
quotes
above. Its aparently wrong but im wondering if this is even possible.
Please advise. Thanks
In Solidarity
JR
cat"banana", "peacock","Weapons" "Mass"
"Destruction"
file=("letter.doc"),sep="\n")
readLines(file, n=-1)
unlink("letter.doc") # tidy up
## difference in blocking
cat("123\nabc", file = "test1")
readLines("test1") # line with a warning
a=con <- file("test1", "r", blocking = FALSE)
readLines(con) # empty
cat(" def\n", file = "test1", append = TRUE)
readLines(con) # gets both
close(con)
unlink("test1") # tidy up
--
View this message in context:
http://www.nabble.com/reading-and-analyzing-a-word-document-tp25691972p25691972.html
Sent from the R help mailing list archive at Nabble.com.
PDXRugger wrote:> > Howdy Y'all, > > So i am looking to read a word document in the following formats(.doc) or > any type of accessible word processor software (e.g. text .txt, notepad, > etc). Had the ability to search certain words, for instance "banana", > "peacock","Weapons" "Mass" "Destruction". Then i could summarize and view > the results. i looked and the only thing i could find was the below where > i want to analyze "letter.doc" and look for the words mentioned in quotes > above. Its aparently wrong but im wondering if this is even possible. > Please advise. Thanks > > In Solidarity > JR >Well... you could make a vector of the words you want to find: to.find <- c( 'banana', 'peacock', 'Weapons' ) Read in the file... file.text <- readLines( 'myFile.txt' ) And recursively apply the grep command in order to determine which lines contain matches for your words: line.matches <- unlist( lapply( to.find, grep, x = file.text ) ) It may do what you want for plain text files, as for Microsoft Word files... well... Sometimes there is a price to pay for using a closed proprietary binary document format. Good luck! -Charlie ----- Charlie Sharpsteen Undergraduate Environmental Resources Engineering Humboldt State University -- View this message in context: http://www.nabble.com/reading-and-analyzing-a-word-document-tp25691972p25692279.html Sent from the R help mailing list archive at Nabble.com.