Created
April 13, 2025 23:54
-
-
Save williamcaban/34ada316f550a4e9e39380bbc6c4d6ca to your computer and use it in GitHub Desktop.
Script to convert 1Password8 export to CSV compatible with Apple Password
This file contains 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
import csv | |
import os | |
def convert_1password_to_apple(input_file, output_file): | |
""" | |
Convert a 1Password CSV export file to a format compatible with Apple Passwords. | |
Apple Passwords import format requires the following columns: | |
- Title | |
- URL | |
- Username | |
- Password | |
- Notes | |
1Password export has: | |
- Title, Url, Username, Password, OTPAuth, Favorite, Archived, Tags, Notes | |
""" | |
# Ensure the input file exists | |
if not os.path.isfile(input_file): | |
print(f"Error: Input file '{input_file}' not found.") | |
return False | |
# Create output directory if it doesn't exist | |
output_dir = os.path.dirname(output_file) | |
if output_dir and not os.path.exists(output_dir): | |
os.makedirs(output_dir) | |
try: | |
# Open the input and output files | |
with open(input_file, 'r', newline='', encoding='utf-8') as infile, \ | |
open(output_file, 'w', newline='', encoding='utf-8') as outfile: | |
# Create readers and writers | |
reader = csv.DictReader(infile) | |
# Define Apple Password format fieldnames | |
# Apple Passwords typically uses these column names | |
apple_fieldnames = ['Title', 'URL', 'Username', 'Password', 'Notes'] | |
# Create a writer with Apple Password format fieldnames | |
writer = csv.DictWriter(outfile, fieldnames=apple_fieldnames) | |
writer.writeheader() | |
# Process each row in the 1Password export | |
for row in reader: | |
# Create notes that include OTPAuth and Tags if present | |
enhanced_notes = row['Notes'] or "" | |
if row['OTPAuth']: | |
enhanced_notes += f"\nOTP Auth: {row['OTPAuth']}" | |
if row['Tags']: | |
enhanced_notes += f"\nTags: {row['Tags']}" | |
# Write the row in Apple Password format | |
writer.writerow({ | |
'Title': row['Title'], | |
'URL': row['Url'], # Note the case difference | |
'Username': row['Username'], | |
'Password': row['Password'], | |
'Notes': enhanced_notes | |
}) | |
print(f"Conversion completed successfully. Output saved to '{output_file}'") | |
return True | |
except Exception as e: | |
print(f"Error during conversion: {str(e)}") | |
return False | |
if __name__ == "__main__": | |
# Define input and output file paths | |
input_file = "1PasswordExport-<your_filename>.csv" | |
output_file = "apple_passwords_import.csv" | |
# Run the conversion | |
convert_1password_to_apple(input_file, output_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment