Ever got fed up with your users using bad practises to read your CSV files? I certainly have! This library will fix all those problems by writing CSV files in a way that ensures bet practices on the part of the reader. Whoever said people know what's best for them, eh?
Add this line to your application's Gemfile:
gem 'scrambly-csv'
And then execute:
$ bundle
Or install it yourself as:
$ gem install scrambly-csv
file = Tempfile.new('foo')
CSV.open(file.path, 'wb') do |csv|
writer = ScramblyCsv::Scrambly.new(csv, ["one", "two", "three", "four"])
writer.write([1, 2, 3, 4])
writer.write([5, 6, 7, 8])
writer.write([9, 10, 11, 12])
end
puts file.path
There are other features that need to implemented to save people from themselves:
- Ensure that users can't just split on comma (difficult!)
- Randomly quote some elements but not others
- Add random escape charaters
In order to contribute:
- Fork it ( https://github.com/ishakir/scrambly-csv/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