Created
January 29, 2016 18:29
-
-
Save kwstannard/6135f77608690c51d0c3 to your computer and use it in GitHub Desktop.
Dashlane csv to KeePass1 xml compatible format
This file contains hidden or 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
#!/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