Rookatu
Rookatu

Reputation: 1507

Cannot import csv file into R

I'm trying to import the csv files from my working directory. There are 3 such files, but for some reason R insists on recognizing only one of them. I can't determine what the pattern is, and if the recognized file is moved out of the folder then nothing is recognized. Here is my code:

files = list.files(pattern="*\\.csv$")

Each of the files is for sure a csv file which I confirmed by inspecting the "Type" column in the windows folder navigator, and to be safe I also saved a copy as CSV and still had the same problem.

Is there an aspect to this I'm unaware of?

Thanks!

Upvotes: 0

Views: 1804

Answers (1)

Rookatu
Rookatu

Reputation: 1507

The issue turned out to be that the file extension for the file that worked was ".csv" and for the ones that didn't was ".CSV". I do not know how or why something like that can happen, but the pattern parameter of the list.files function is case sensitive.

Using the parameter setting ignore.case = TRUE solved this issue.

Upvotes: 2

Related Questions