Skip to content

Instantly share code, notes, and snippets.

Created February 24, 2022 02:55
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schwa/2ec8a1aa80392d9b75744f829065d573 to your computer and use it in GitHub Desktop.
Save schwa/2ec8a1aa80392d9b75744f829065d573 to your computer and use it in GitHub Desktop.
Python script to help import 1Password data into iCloudKeychain
# Quick script to help filter records from a 1Password .csv export for importing into Safari/iCloud Keychain
# Safari rejects records with no username, password or url. This script takes your 1Password export and "splits" it
# into two CSV file, one with these records filtered out, and one with just records with the required fields. You can then import the
# filtered .csv file directly into Safari and should not get import warnings.
# This script also filters out records with the "Archive" field set to true - these are 1Password records that you previously Trashed
import csv
from pathlib import Path
import urllib
missing_data = []
filtered = []
path = Path("1PasswordExport.csv")
reader = csv.DictReader(
for record in reader:
if record["Archived"] == "true":
print("Skipping record (archived)")
# Uncomment this to reduce the website url to just the domain.
# url = record["Url"]
# parts = urllib.parse.urlparse(url)
# domain = parts.netloc
# record["Url"] = domain
if not record["Username"] or not record["Password"] or not record["Url"]:
print("Skipping record (no username, password or url")
path = Path("1PasswordExport-Filtered.csv")
writer = csv.DictWriter("w"), reader.fieldnames)
path = Path("1PasswordExport-MissingData.csv")
writer = csv.DictWriter("w"), reader.fieldnames)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment