Skip to content

Instantly share code, notes, and snippets.

@tycho
Last active February 19, 2021 22:45
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tycho/b9cfbc1dc12847e5b88e67d9b4c9c64f to your computer and use it in GitHub Desktop.
Save tycho/b9cfbc1dc12847e5b88e67d9b4c9c64f to your computer and use it in GitHub Desktop.
Demangle the LastPass CSV export format
#!/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