I have multiple csv files in a folder, how to import them efficiently?

Hello! Nice to meet everyone, I'm a refresher for R.

Recently I've got multiple csv files in a folder, and I want to analyze them in Rstudio.
The number of files are over 30+, so I hope to import them efficiently, rather than using read_csv() to load
them one by one.

What is the most recommended way to import multiple csv files?

I've think of 2 solutions right now, but I'm not sure if it's smart way:

  1. Upload the zip file containing all csv files, and unzip the folder(But I'm currently stuck in the unzip step, encounter some error)

  2. List all csv files in the folder in R, and use read_csv() to read all of them in a for loop.

Please give me some advice, thank you!

You could use purrr. Examples:

Try this and report back

myData <- read_csv("foo.txt.gz")

Thank you, I decided to hardcode it.

This topic was automatically closed 21 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.