Skip to content

Instantly share code, notes, and snippets.

@mauricesvay
Created January 29, 2017 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mauricesvay/916a6f60ced66bd55ffe666a99bc9e0f to your computer and use it in GitHub Desktop.
Save mauricesvay/916a6f60ced66bd55ffe666a99bc9e0f to your computer and use it in GitHub Desktop.
<?php
/*
How to use:
- In Dashlane, export data as CSV
- Copy this file in the same folder as the exported csv
- Run in a terminal: php dashlane-to-1password.php
- This should generate 2 files: Dashlane_passwords.csv and Dashlane_others.csv
- In 1Password, import Dashlane_passwords.csv
- Do whatever you want with Dashlane_others.csv
*/
$row = 1;
$filename = "Dashlane Export.csv";
$out = array();
$file_out = fopen("Dashlane_passwords.csv", 'w');
$others = array();
$file_others = fopen("Dashlane_others.csv", 'w');
if (($handle = fopen($filename, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",", '"')) !== FALSE) {
if (count($data) === 5) {
$out[] = array(
$data[0],
$data[1],
$data[2],
$data[3],
$data[4],
);
} else {
$others[] = $data;
}
}
fclose($handle);
foreach ($out as $fields) {
fputcsv($file_out, $fields);
}
foreach ($others as $fields) {
fputcsv($file_others, $fields);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment