Created
November 29, 2017 00:21
-
-
Save luizirber/0d6e38dff60bbe0f143724425b735387 to your computer and use it in GitHub Desktop.
A small Python script to convert lastpass CSV files to a format that Password Gorilla can import
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
#!/usr/bin/env python | |
""" | |
A small Python script to convert lastpass CSV files to a format that Password Gorilla can import. | |
Usage: | |
python convert.py lastpass.csv output.csv | |
output.csv can now be imported into Password Gorilla | |
""" | |
import csv | |
import sys | |
import uuid | |
with open(sys.argv[1], 'r') as inputf: | |
reader = csv.DictReader(inputf) | |
with open(sys.argv[2], 'w') as output: | |
writer = csv.DictWriter(output, | |
fieldnames=['uuid', 'group', 'title', | |
'url', 'user', 'password', | |
'notes']) | |
writer.writeheader() | |
uuids = set() | |
for row in reader: | |
new_uuid = uuid.uuid4() | |
while new_uuid in uuids: | |
new_uuid = uuid.uuid4() | |
uuids.add(new_uuid) | |
entry = { | |
'uuid': new_uuid, | |
'group': row['grouping'], | |
'title': row['name'], | |
'url': row['url'], | |
'user': row['username'], | |
'password': row['password'], | |
'notes': row['extra'].replace('\n', '\\n') | |
} | |
writer.writerow(entry) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment