Skip to content

Instantly share code, notes, and snippets.

@ragulka
Created September 5, 2016 07:44
Show Gist options
  • Save ragulka/13f9d7a5ccb7732555b17f293dc1201a to your computer and use it in GitHub Desktop.
Save ragulka/13f9d7a5ccb7732555b17f293dc1201a to your computer and use it in GitHub Desktop.
Convert Dashlane Export CSV to a 1Password compatible CSV
<?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 );
@carlvlewis
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment