Skip to content

Instantly share code, notes, and snippets.

@kivanio
Forked from kalmanh/converter_script.rb
Created October 24, 2016 19:34
Show Gist options
  • Save kivanio/7c7708ecd98ada25d03766f0c2fc05a2 to your computer and use it in GitHub Desktop.
Save kivanio/7c7708ecd98ada25d03766f0c2fc05a2 to your computer and use it in GitHub Desktop.
Ruby script to convert .mdb db file into .csv
# Export data from Microsoft Access .mdb database into .csv files
# using https://github.com/brianb/mdbtools
# Install with homebrew - "brew install mdbtools"
class ConverterScript
tables = `mdb-tables -d , your_db_name.mdb`.chop.split(",")
tables.each do |table|
exists = system("mdb-export your_db_name.mdb '#{table}'")
`mdb-export your_db_name.mdb '#{table}' > #{table.gsub(" ", "_")}.csv` if exists
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment