Created
October 18, 2022 20:17
-
-
Save ckocyigit/9a7ee85972e8cb4748e3226920d2d543 to your computer and use it in GitHub Desktop.
Convert Bitwarden CSV to Passbolt CSV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import csv | |
| INPUT_FILENAME: str = 'bitwarden_export_20221018212756.csv' | |
| OUTPUT_FILENAME: str = 'passbolt_converted.csv' | |
| def csvParse(file): | |
| with open(file, newline='') as csvfile: | |
| rows = [] | |
| csvreader = csv.reader(csvfile, delimiter=',', quotechar='"') | |
| header = next(csvreader) | |
| for row in csvreader: | |
| rows.append(row) | |
| return header, rows | |
| output = open(OUTPUT_FILENAME, 'w') | |
| writer = csv.writer(output) | |
| newRow = ["Group","Title","Username","Password","URL","Notes"] | |
| _, rows = csvParse(INPUT_FILENAME) | |
| for row in rows: | |
| if row[2] != "login": | |
| continue | |
| if row[0] == "": | |
| row[0] = "root" | |
| writer.writerow(newRow) | |
| newRow[0] = row[0] | |
| newRow[1] = row[3] | |
| newRow[2] = row[8] | |
| newRow[3] = row[9] | |
| newRow[4] = row[7] | |
| newRow[5] = row[4] | |
| writer.writerow(newRow) | |
| output.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment