How to Join Database from 2 Different CSV Files?

0 Comments
Editor Ratings:
User Ratings:
[Total: 0 Average: 0]




This article covers a simple method to join database from 2 different CSV files. Combine database from 2 different CSV files is relatively easy if both files have the same keys in the same order. But if you want to combine database from CSV files that do not have the same keys in exact same order, there is no direct way. For such files, you can use xsv to combine the database.

xsv is an open-source command-line tool that allows you to combine a database that is spread over 2 different CSV files. All you need is the same keys in both files that can be arranged in any order. On the basis of the same keys, you can call both the files from the command line and combine the database. Apart from combining database, xsv can do many other operations as well including indexing, analyzing, splitting, slicing, search, and more.

How to Join Database from 2 Different CSV Files?

Also read: Free Nirsoft Utility to Read CSV, TSV Data from Output of CLI tools

Join Database from 2 Different CSV Files with xsv

To join database from 2 different CSV files, download the xsv tool from here. It’s available on GitHub and the ‘Releases’ section packs 9 assets. There is one for Linux, one for macOS, and four for Windows including two source code files. The tool is available for both, x86 and x64 versions. Each version then has GNU and MSVC builds.

Join Database from 2 Different CSV Files with xsv

The GNU file uses the MinGW build tools and produces binaries that use the GNU ABI. The MSVC file uses the Visual Studio build tools and produces binaries that use the Microsoft ABI. The MSVC file is more compatible with other Windows binaries/libraries. However, you can download and use any of those based on your Windows architecture.

All 4 for files for Windows OS are ZIP files each containing the respective “xsv.exe” executable file. Simply download a file as per your Windows architecture and extract the “xsv.exe” file to a folder. Then, move your CSV files to the same folder.

join database from 2 CSV files

Now, open the command prompt on your PC and navigate to that folder where you have “xsv.exe” file along with your CSV files. Then, run the following command to join the database:

xsv join <KEY> <File1.CSV> <KEY> <File2.CSV>

For example, the names of the CSV files are Database1.csv and Database2.csv. Both files have the same key named “ID”. Then, run the following command to join the database:

xsv join ID Database1.csv ID database

Running this command join both files and show you the results in the command prompt.

join database from 2 different CSV files

Apart from joining files, xsv has many more functions that you can use to perform various operations on CSV files. You can check out all the xsv commands along with their working here.

Closing Words

This article covers a free command-line tool to join the database from different CSV files without having the same keys in the same order. This allows you to easily join data from two files in the command-line without the need of editing the files to make them compatible database-joining.

Editor Ratings:
User Ratings:
[Total: 0 Average: 0]
Free/Paid: Free

Leave A Reply

 

Get 100 GB FREE

Provide details to get this offer