Last active
February 19, 2021 22:45
-
-
Save tycho/b9cfbc1dc12847e5b88e67d9b4c9c64f to your computer and use it in GitHub Desktop.
Demangle the LastPass CSV export format
This file contains 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
#!/usr/bin/python3 | |
# | |
# Usage: ./lastpass-demangle.py lastpass-export.csv > fixed-lastpass-export.csv | |
# | |
import csv | |
import html | |
import fileinput | |
import sys | |
# LastPass export columns: | |
# url,username,password,extra,name,grouping,fav | |
reader = csv.reader(fileinput.input()) | |
writer = csv.writer(sys.stdout, lineterminator='\n') | |
# Write out header, unmodified | |
line = next(reader) | |
writer.writerow(line) | |
# Now fix up all data rows | |
for line in reader: | |
# html.unescape each column, e.g. & -> & | |
line = list(map(html.unescape, line)) | |
# Strip the "grouping" column, it doesn't have any useful data in my LastPass | |
# export and I'd prefer to set up folders and groups myself after importing | |
# to Bitwarden. | |
line[5] = '' | |
writer.writerow(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment