Will import a CSV as an array of hashes. Or will export a CSV from an array of hashes (if given a column list).
array_of_hashes, columns = CSVHash('path_to_csv.csv')
Note the hash will have strings for keys and will remove all surrounding whitespace
string = CSVHash(array_of_hashes,[:column,"names","in",:order])
csv-hash supports nested hashes. A column tree of the structure (note the double underscore):
one,two__foo,two__bar__three,two__bar__four 1, 2, 3, 4,
will generate:
{ 'one' => '1', 'two' => { 'foo' => '2', 'bar' => {'three' => '3', 'four' => '4'} } }
-
Remove dependency on Fast CSV
-
Support auto column generation
-
Generate hash of arrays
-
Turn into CSVHash object which contains column structure and other metadata
-
Sequel integration
-
Arbitrary model support
-
Fork the project.
-
Make your feature addition or bug fix.
-
Add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-
Send me a pull request. Bonus points for topic branches.
Copyright © 2010 Tal Atlas. See LICENSE for details.