Skip to content

Instantly share code, notes, and snippets.

@chilang
Last active August 29, 2015 14:04
Show Gist options
  • Save chilang/736ee9cb5ff5606883ef to your computer and use it in GitHub Desktop.
Save chilang/736ee9cb5ff5606883ef to your computer and use it in GitHub Desktop.
Import iOS Notes into 1Password
1. Backup iPad/iPhone to Mac (without encryption)
2. Locate backup folder and run https://code.google.com/p/iphone-dataprotection/:
python python_scripts/backup_tool.py ~/Library/Application\ Support/MobileSync/Backup/XXXXXXX outdir
3. Open sqlite db under using SquirrelSQL:
outdir/HomeDomain/Library/Notes/notes.sqlite
4. Run SQL query and export the result as CSV:
SELECT n.ztitle, b.zcontent FROM znote n, znotebody b where n.z_pk = b.z_pk
5. Run notes.py on exported csv to convert it into plain-text formattted csv
6. Import csv into 1Password for Mac as Secure Notes
import csv
def read_csv(file):
rows = []
with open(file, 'rb') as csvfile:
reader = csv.reader(csvfile)
for r in reader:
rows.append(r)
return rows
def notes_to_plain_text(rows):
return [[line[0], line[1].replace('<div>','\n').replace('</div>','').replace('<br>','').replace('&nbsp;', ' ')] for line in rows]
def export_csv(rows, file):
with open(file, 'wb') as csvfile:
writer = csv.writer(csvfile, quoting=csv.QUOTE_ALL)
for r in rows:
writer.writerow(r)
def convert(input, output):
rows = read_csv(input)
rows_fmt = notes_to_plain_text(rows)
export_csv(rows_fmt, output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment