Skip to content

Instantly share code, notes, and snippets.

@rsc-awhite
Last active October 4, 2017 02:29
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 rsc-awhite/640b7122c6619c851c101c4348e89313 to your computer and use it in GitHub Desktop.
Save rsc-awhite/640b7122c6619c851c101c4348e89313 to your computer and use it in GitHub Desktop.
require 'csv'
import_file = "./keepass-export.csv"
export_file = "./passwordstate-import.csv"
headers = "Title,UserName,Description,Notes,URL,Password,ExpiryDate,WebUser_ID,WebPassword_ID,\n"
keepass_headers = ['Group', 'Title', 'Username', 'Password', 'URL', 'Notes']
rows = headers
CSV.foreach(import_file, headers: true) do |row|
this_row = [ row[1], row[2], '', row[5], row[4], row[3], '', '', ''].to_csv
rows << this_row
end
File.open(export_file, 'w') { |file| file.write(rows) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment