I hope you do not mind helping me with this likely quite simple problem I am having.
I am trying to read multiple .csv files within a folder into R and combine these files into one longer file. I have done some research and found that there are a bunch of different ways to successfully do this! However, I am running into one small problem: The .csv files that I am working with are use semicolons to separate data rather than using a comma as usual.
When I am running my code, I am therefore having a problem reading in these data files.
I am hoping someone doesn't mind helping with this .
Below I have included what is my current, unsuccessful code. Here you can see that I am trying to read in multiple files (a number of files that will increase weekly). But do not know how to take into consideration the ";" separator in my .csv files.
Thank you for your help. This however does not solve my issue. My issue is that when automatically reading in multiple .csv files into R, I am unsure how to take into account the delim=";" statement. I will edit my original post with my current, unsuccessful code.
The error code that I get when I run the code you have referenced in this comment is the following:
"Error in read_delimited(file, tokenizer, col_names = col_names, col_types = col_types, :
argument "file" is missing, with no default"
Thank you for your feedback so far
I am unfamiliar with the reprex function but I ran it as you suggested and it says the following:
"``` r
data_csv <- ldply(folderfiles, read_delim(delim = ";"))
#> Error in ldply(folderfiles, read_delim(delim = ";")): could not find function "ldply"
<sup>Created on 2021-05-08 by the [reprex package](https://reprex.tidyverse.org) (v2.0.0)</sup>"
For the first, you should use the quoted name of the file ; and for the second you need the plyr library loaded. Once you have it working for a single file, come back to do multiple.
Thanks for the help. I must be missing something here because this is an easy task to read one file. however I am still confused regarding what will make this a successful code. I will continue researching.
Now that you can read one file, you will want to use a function that takes a list of file names (perhaps a list returned from another function) and sends them to a function that reads the single file, replacing the hard-coded file name with a variable designation.
There are a number of ways to do this. If you are already using {tidyverse} packages, I'd start with {purrr}. Otherwise there are Maplapply and for.
Thank you for the help everyone. @andresrcs this is an excellent solution!
I have also found that the read_bulk function in the readbulk package is successful as well!