Skip to content

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

@tpbarrette

Description

@tpbarrette

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions