We need to import our passwords from a format that is not explicity understood by Bitwarden.
The old tool exports to CSV, and I’ve build a simple Python script to change some column names as well as inserting a couple of new columns. The script I’m using is below:
import os, re, glob
import pandas as pd
df=pd.read_csv(glob.glob('accounts_*.csv')[0])
df['collections']=re.sub('folder-', '', os.path.basename(os.getcwd()))
df['type']='login'
result = df.rename(columns={'nickname': 'name', 'additionalInfo': 'notes', 'url': 'login_uri', 'username': 'login_username', 'password': 'login_password', 'twofaSecret': 'login_totp'})
result.to_csv("test.csv")
It’s working well except for one issue, each record has a notes field that can span multiple lines, e.g.
nickname,username,password,additionalInfo
Some site,username,PASSWORD,Some website we use
Another site,username2,PASSWORD2,A longer description with a carriage return
And some more text
And more
And more
All the records need the same two extra columns, so I’m adding them this way:
df[‘collections’]=’Some Collection’
df[‘type’]=’login’
The problem is it adds those columns on the multi-line fields, e.g.
collections,type,name,login_username,login_password,notes
Some Collection,login,username,PASSWORD,Some website we use
Some Collection,login,Another site,A longer description with a carriage return
Some Collection,login,And some more text
Some Collection,login,And more
Some Collection,login,And more
Actually Bitwarden is able to import the file successfully, just every line in the note is prefixed with Some Collection,login,
.
I could use regex to remove the unwanted text, but I wondered if I could use pandas in a different way so it didn’t recognise every newline as a new record?
Thanks for any tips!