dashbitco / nimble_csv

A simple and fast CSV parsing and dumping library for Elixir
https://hexdocs.pm/nimble_csv
772 stars 51 forks source link

Excel-Friendly default implementation #45

Closed LostKobrakai closed 4 years ago

LostKobrakai commented 4 years ago

I'm wondering if there could be an excel friendly default implementation besides NimbleCSV.RFC4180 based on https://underthehood.meltwater.com/blog/2018/08/08/excel-friendly-csv-exports-with-elixir/.

This seems to be working fine for recent versions of Excel, Numbers, OpenOffice based on my quick research, while RFC4180 just produces garbage in Excel.

josevalim commented 4 years ago

We don't have plans to tackle it but a pull request is welcome. In particular, I think we can have the encoding option given when generating the parser/encoder, which should be more efficient. Recent Elixir versions can also automatically remove the BOM when working with file streams. Thanks!

josevalim commented 4 years ago

@LostKobrakai Can you please give master a try?

I have renamed the module to NimbleCSV.Spreadsheet and I have optimized the code a bit.

LostKobrakai commented 4 years ago

Looks great and seems to work fine on my side.

LostKobrakai commented 4 years ago

Not sure if it's worth it, but now there are two @compile module attributes to inline calls. Maybe those can/should be merged?

josevalim commented 4 years ago

I like to keep them close to where they are used. They are actually 3 calls, all of them are automatically merged. :)