Skip to content

Instantly share code, notes, and snippets.

@kwstannard
Created January 29, 2016 18:29
Show Gist options
  • Save kwstannard/6135f77608690c51d0c3 to your computer and use it in GitHub Desktop.
Save kwstannard/6135f77608690c51d0c3 to your computer and use it in GitHub Desktop.
Dashlane csv to KeePass1 xml compatible format
#!/usr/bin/ruby
#
# Most of this taken from here: https://gist.github.com/jmazzi/436947
require 'csv'
require 'pathname'
# CHANGE THIS
input_file = Pathname("PATH/TO/CSV").expand_path
output_file = Pathname("~/pwds.xml").expand_path
def write_row(f,name,site,user="",email="",pwd,note)
f.puts " <entry>"
f.puts " <title>#{name}</title>"
f.puts " <username>#{user}</username>"
f.puts " <password>#{pwd}</password>"
f.puts " <url>#{site}</url>"
f.puts " <comment>#{note}</comment>"
f.puts " </entry>"
end
File.open(output_file, 'w') do |f|
f.puts '<!DOCTYPE KEEPASSX_DATABASE>'
f.puts '<database>'
f.puts ' <group>'
f.puts " <title>passwords</title>"
CSV.open( input_file ).each do |(*args)|
write_row(f,*args)
end
f.puts ' </group>'
f.puts '</database>'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment