DEV Community

loading...

Merge multiple CSV files and remove duplikats (e.g. Keepass)

Sebastian Korotkiewicz
IT Geek interested in all the things! System administration, web development and more!
・2 min read

I would like to present you a simple script which I wrote when I needed to merge the passwords database from LastPass to my current KeepassXC database.

screenshot

Let's start with my example, you want to migrate from LastPass but you already have existing passwords in Keepass.
You can use merge tool built in Keepass but unfortunately it adds new records without checking if there is already one, which causes duplikats in the database.

That's why I wrote this script which will merge multiple databases exported in CSV and remove duplikats automatically.
But don't worry, if even one column differs, it does not remove it but adds it as a new one. This way you will not lose any entries.

ProHint: If you are esporting a database from LastPass (or other services), add the exported CSV first to the new Keepass database and set the columns you have on your other Keepass database and export as new CSV file. This will make sure you have the same columns in the current database and the new one.

My columns look like this:
Group | Title | Username | Password | URL | Notes

Usage

To install and start the CSV database merge you can easily install from npmjs.com

$ npm install merge-csv-keepass -g
or
$ yarn global add merge-csv-keepass
Enter fullscreen mode Exit fullscreen mode

It is very easy to use, after installation you have access to a new command merge-csv-keepass where you just need to add few arguments and you are done!

Example, we have a database db1.csv and db2.csv we want to merge them into a file merged_db.csv to do this we run the command:

merge-csv-keepass -source db1.csv db2.csv -output merged_db.csv
Enter fullscreen mode Exit fullscreen mode

Done! Simple, isn't it?

Keep in mind that the script does not check if the output file exists! If it exists it will overwrite it!

Of course you can add more databases than just two to merge, or even just one database to only remove duplikats from it.

The whole project is open source and available on Github.

GitHub logo skorotkiewicz / merge-csv-keepass

Merge multiple databases and remove dublikats from CSV files (e.g. Keepass)

Enjoy your merging! :)

Discussion (0)