read_csv() does not differentiate upper/lowercase in file name

Hello, may I ask a silly question about read_csv()? Not sure what's wrong, it seems not differentiating the upper/lowercase in the file name. For instance, if my file name is "This_is_number#.csv", I used the following code to read different .csv file in a loop,

a <- 'This_is_number'
b <- c(1,2,3,4,5,6)
for (i in 1:length(b)){
filein <- paste0(a, b[i], '.csv')
datalist <- read_csv(filein)

but read_csv() can load the file even if I mistakenly set a <- 'this_Is_Number', is there a way to make it read the exact file name? Thanks.

Hi @zhengchen,
Several operating systems have case-insensitive file systems, so this is not an R/RStudio/readr problem. You will find that you cannot write files with the same name that differ only in the case of the letters; one will be overwritten or you will get a "file already exists" message. The solution is to use another schema in the naming to distinguish sets of files. This may entail bulk renaming of files if they originate on a system with case-sensitive names.

1 Like

Thanks a lot @DavoWW. I didn't notice this previously, I guess I'd be careful on filename schema in the future to avoid potential risks.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.