ruby / csv

CSV Reading and Writing
https://ruby.github.io/csv/
BSD 2-Clause "Simplified" License
182 stars 114 forks source link

feature: add option to limit length of strings #271

Closed foonlyboy closed 1 year ago

foonlyboy commented 1 year ago

Hi at the ruby csv I'd like to suggest a new feature.

There should be an option to limit the length of the strings generated as fields.

The prime use of generating csv is, to export data to customers, for them to import that into Excel or LibreOffice. That apps do have a limited cell size. With LibreOffice that is 2^31-1

I'd like to suggest, to add an option to CSV#generate to ease to stay within the limits.

My idea would be to add a new option to limit the column length.

let's call that option :limit_column_size for a start:

one might also think about another way to express that: compatible: :LibreOffice

kou commented 1 year ago

How about using the write_converters: option? https://ruby.github.io/csv/doc/csv/recipes/generating_rdoc.html#label-Converting+Fields

foonlyboy commented 1 year ago

Hi Sutuo, sorry for me asking.

On Sat, Jan 21, 2023 at 6:10 AM Sutou Kouhei @.***> wrote:

How about using the write_converters: option?

https://ruby.github.io/csv/doc/csv/recipes/generating_rdoc.html#label-Converting+Fields

— Reply to this email directly, view it on GitHub https://github.com/ruby/csv/issues/271#issuecomment-1399181171, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKLJCHV5S3RP5TIBWU4IFR3WTNVUPANCNFSM6AAAAAAUAZD6SA . You are receiving this because you authored the thread.Message ID: @.***>

kou commented 1 year ago

No problem.