Created
September 5, 2016 07:44
Star
You must be signed in to star a gist
Convert Dashlane Export CSV to a 1Password compatible CSV
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
<?php | |
// Place this file in th same directory with your Dashlane Export.csv | |
// and run using the following command in your Terminal: | |
// | |
// php convert.php | |
// | |
// This will create a file named fixed.csv, which should work for | |
// 1Password 6 import. In addition to moving fields into correct places, | |
// this will also try to remove hashed lines {...}, as well as lines where | |
// the title (first column) is empty. It won't remove address and identity | |
// entries though, as there's no way to reliably distinguish them from login items. | |
// | |
// Note - you will need to have PHP installed and executable in your computer | |
// in order to run this script. Instructions on installing PHP are outside the scope of this | |
// script, but here's a start: http://php.net/manual/en/install.php | |
// | |
// Note: Mac OSX already comes with PHP installed. | |
$rows = array(); | |
if ( ( $handle = fopen( 'Dashlane Export.csv', 'r' ) ) !== false ) { | |
while ( ( $data = fgetcsv( $handle ) ) !== false ) { | |
// skip hash or empty lines | |
if ( strpos( $data[0], '{' ) !== false || empty( $data[0] ) ) { | |
continue; | |
} | |
// handle passwords with no url & no username | |
if ( empty( $data[1] ) && empty( $data[3] ) ) { | |
$data[3] = $data[2]; | |
$data[2] = ''; | |
} | |
// handle logins with both username & email | |
elseif ( $data[3] && filter_var( $data[3], FILTER_VALIDATE_EMAIL) ) { | |
$email = $data[3]; | |
$pass = $data[4]; | |
$notes = ! empty( $data[5] ) ? $data[5] : ''; | |
$data[3] = $pass; | |
$data[4] = $notes; | |
$data[5] = $email; | |
} | |
$rows[] = $data; | |
} | |
fclose( $handle ); | |
} | |
$handle = fopen( 'fixed.csv', 'w' ); | |
foreach ( $rows as $row ) { | |
fputcsv( $handle, $row ); | |
} | |
fclose( $handle ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! Thanks for this. Still getting an error for some reason when trying to import the newly generated
fixed.csv
from this script. Any ideas?