CsvFiles
CSV files generator for large datasets. This gem let you save large datasets as soon as the row limit (default to 10_000) is reach.
Installation
Add this line to your application's Gemfile:
gem 'csv_files'
And then execute:
$ bundle
Or install it yourself as:
$ gem install csv_files
Usage
csv = CsvFiles::Generator.new("path-to-export-file", ['header', 'values', 'goes', 'here'], 10_000)
You need to define you storing method as follow:
csv.store_fn = lambda do |filename, text|
puts filename
puts text
# You can store this to S3 or your file system in this block
end
To insert data you can use the following:
csv << ['my', 'values', 'go', 'here']
A file will automatically be created as soon as the limit is reach. If the limit isn't reach, call the following method:
csv.store
Contributing
- Fork it ( https://github.com/[my-github-username]/csv_files/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request