In this post, I provide a simple script for merging a set of files in a directory into a single, large dataset. I recently needed to do this, and it’s very straightforward.
Set the Directory
Begin by setting the current working directory to the one containing all the files that need to be merged:
Getting a List of Files in a Directory
Next, it’s just a case of getting a list of the files in the directory. For this, the list.files() function can be used. As I haven’t specified any target directory to list.files(), it just lists the files in the current working directory.
If you want it to list the files in a different directory, just specify the path to list.files. For example, if you want the files in the folder C:/foo/, you could use the following code:
Merging the Files into a Single Dataframe
View original post 146 more words