Skip to content

Instantly share code, notes, and snippets.

@oprietop
Created December 20, 2023 10:10
Show Gist options
  • Save oprietop/9730bb47efe79634014a135dd83816c2 to your computer and use it in GitHub Desktop.
Save oprietop/9730bb47efe79634014a135dd83816c2 to your computer and use it in GitHub Desktop.
Format firefox exported passwords for Keepass
import datetime
def epoch2date(e):
return datetime.datetime.fromtimestamp(int(e)/1000).strftime('%Y/%m/%d %H:%M:%S')
file1 = open('logins.csv', 'r')
lines = file1.readlines()
if lines:
print('"url","username","password","formActionOrigin","guid","timeCreated","timeLastUsed","timePasswordChanged"')
for line in lines[1:]:
list = line.replace(",,", ",").rstrip().strip('"').split('","')
list[5] = epoch2date(list[5])
list[6] = epoch2date(list[6])
list[7] = epoch2date(list[7])
print('"{}"'.format('","'.join(list)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment