Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drive_download produces error when file name contains "+" #292

Closed
tpbarrette opened this issue Jan 27, 2020 · 0 comments
Closed

drive_download produces error when file name contains "+" #292

tpbarrette opened this issue Jan 27, 2020 · 0 comments

Comments

@tpbarrette
Copy link

I have been attempting to use a "for loop" in conjunction with "drive_download" to download a list of files from Google Drive one at a time, manipulate the files, save a new CSV file, and then delete the file that I downloaded from local storage. When the files in the list contain plus symbols (+) in the name, the loop quits and I get the following error message: Error: 'file' does not identify at least one Drive file.

To verify this, I have created two files, Test.xlsx, and Test+.xlsx (I use CSV versions of these files), which contain the following text in cell A1:

This;is;a;test

If the Test+ file is not present in Google Drive, the code will run fine. If it is present, the error message is shown. Note that I have not specified a working directory since I am working in R studio using a project file.

Testfile <- drive_find(pattern = "Test")#Identifies all Delay Results files
Testfilenames <- unlist(Testfile[,1])#Removes extraneous columns from drive_find results

for(i in Testfilenames){
  drive_download(as.character(paste(i)))#Downloads file from Google Drive based on list of file names
  a <- as.data.frame(cSplit(a,'V1',sep = ";"))#Equivalent of "Text To Columns" in Excel
  a$filename <- i#Adds a column with the file name in case the files need to be combined in the future
  write.csv(a, as.character(paste(i, ".csv", sep = "")))#Creates a new CSV file
  unlink(i)#Deletes original file from local drive
  }

Test+.xlsx
Test.xlsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant