(Re-posting after including R-help) Thanks Ben, Changing './' and '.' and shQuote() didn't work. I'm trying dQuote(). For your information the 'name' value retrieved is --> Hội những người đồng hành cùng
I guess the string is in Vietnamese language. As you would have observed in error message it wasn't interpreted as above but some other nonsensical characters (posts_H<U+1ED9>i nh<U+1EEF>ng ngu<U+1EDD>i d<U+1ED3>ng > hành cùng line). Is there a workaround to handle such strings ? Regards, Sunny On Mon, Mar 21, 2016 at 6:29 PM, Sunny Singha <sunnysingha.analyt...@gmail.com> wrote: > Thanks Ben, > Changing './' and '.' and shQuote() didn't work. I'm trying dQuote(). > For your information the 'name' value retrieved is --> Hội những người > đồng hành cùng > > I guess the string is in Vietnamese language. As you would have > observed in error message it wasn't interpreted as above but some > other nonsensical characters (posts_H<U+1ED9>i nh<U+1EEF>ng > ngu<U+1EDD>i d<U+1ED3>ng >> hành cùng line). > Is there a workaround to handle such strings ? > > Regards, > Sunny > > On Mon, Mar 21, 2016 at 5:35 PM, Ben Tupper <btup...@bigelow.org> wrote: >> Hi, >> >> You are defeating the purpose of the file.path() function by providing a >> path separator in the first argument; you used './', but try instead... >> >> my.file1 <- file.path('.', paste0('likes','_',name,'_',grp_id,'.csv')) >> >> Also, there appear to be spaces in the 'name' argument - that might be >> causing you an issue but it is hard to know. You might try wrapping the >> value of my.file1 in quotes using shQuote() or maybe even dQuote() - I'm not >> sure as I am not on Windows. >> >> Cheers, >> Ben >> >>> On Mar 21, 2016, at 7:53 AM, Sunny Singha <sunnysingha.analyt...@gmail.com> >>> wrote: >>> >>> Please guide, >>> I'm exporting data in '.csv' format in the Windows user directory, I >>> have full access to. The write operation happens within a for loop. >>> >>> Each iteration exports data in csv format in the user directory. The >>> issue is that the data gets exported for all the 9 iterations but >>> fails for 10th iteration giving below error message. >>> >>> Error in file(file, ifelse(append, "a", "w")) : >>> cannot open the connection >>> In addition: Warning message: >>> In file(file, ifelse(append, "a", "w")) : >>> cannot open file './/posts_H<U+1ED9>i nh<U+1EEF>ng ngu<U+1EDD>i >>> d<U+1ED3>ng hành cùng line_752518568125567.csv': Invalid argument >>> Called from: file(file, ifelse(append, "a", "w")) >>> >>> The export directory path is current directory with 'name' extracted as >>> below: >>> my.file1: .//likes_H<U+1ED9>i nh<U+1EEF>ng ngu<U+1EDD>i d<U+1ED3>ng >>> hành cùng line_752518568125567.csv >>> my.file2: .//posts_H<U+1ED9>i nh<U+1EEF>ng ngu<U+1EDD>i d<U+1ED3>ng >>> hành cùng line_752518568125567.csv >>> >>> I wondering if the error is due to the the complicated filename ? >>> Below is the line of code I have used within loop to export data. >>> >>> my.file1 <- file.path('./', paste0('likes','_',name,'_',grp_id,'.csv')) >>> my.file2 <- file.path('./', paste0('posts','_',name,'_',grp_id,'.csv')) >>> >>> write.csv(posts_frame, file=my.file2, row.names = F) >>> write.csv(likes_frame, file = my.file1, row.names = F) >>> >>> Regards, >>> Sunny >>> >>> ______________________________________________ >>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >>> https://stat.ethz.ch/mailman/listinfo/r-help >>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >>> and provide commented, minimal, self-contained, reproducible code. >> >> Ben Tupper >> Bigelow Laboratory for Ocean Sciences >> 60 Bigelow Drive, P.O. Box 380 >> East Boothbay, Maine 04544 >> http://www.bigelow.org >> ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.