Welcome folks today in this tutorial we will be looking at how to merge
multiple csv files using node
dependency csvmerger
in python. All the source code of the application will be given as shown below
Get Started
In order to get started you need to install the global
library csvmerger
library on your system by executing the below command
npm i -g csvmerger
As this is node dependency you should be having node
installed before you install this library. After successful installation of this library you can now use this library as a command as shown below
csv-merger -o output.csv file1.csv file2.csv
Basically in this command it will merge two input csv files into one output file that is mentioned with the help of -o
flag which stands for output as shown below
As you can see it has merged both the input csv
files into one output.csv
file. Now we will be using this library in python to do this task programmatically as shown in this block of code
Now just make an app.py
file and copy paste the following code
app.py
1 2 3 4 5 6 |
import subprocess import sys subprocess.run(["csv-merger", "-o outputfile.csv","uploads/file1.csv","uploads/file2.csv"]) |