JoshClose / CsvHelper

Library to help reading and writing CSV files
http://joshclose.github.io/CsvHelper/
Other
4.76k stars 1.07k forks source link

Any planned support for fixed width files? #886

Closed reloaded closed 6 years ago

reloaded commented 6 years ago

I understand fixed width files are not necessarily CSV files... Can CsvHelper add support for fixed width files?

http://www.softinterface.com/Convert-XLS/Features/Fixed-Width-Text-File-Definition.htm

jamesbascle commented 6 years ago

I believe the plan for that is to have contrib packages for various rectangular file formats that don't fit for csv. There is an Excel one at the moment.

On Dec 28, 2017 4:46 PM, "Jason Harris" notifications@github.com wrote:

I understand fixed width files are not necessarily CSV files... Can CsvHelper add support for fixed width files?

http://www.softinterface.com/Convert-XLS/Features/Fixed- Width-Text-File-Definition.htm

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/JoshClose/CsvHelper/issues/886, or mute the thread https://github.com/notifications/unsubscribe-auth/AD_ohWqB_9IqpfzIaZ26bgfr1VbYYHGYks5tFAwdgaJpZM4ROrHl .

JoshClose commented 6 years ago

There are at least 2 Excel ones that I know of. I'm actually planning on writing a fixed width parser at some point, since it's so close to a CSV file. It'll probably be a while before that happens though.

reloaded commented 6 years ago

Thanks for the quick response. I've got the need to use fixed width alongside CSV reading/writing. It's a shame that fixed width is not in the library yet.. But I understand. I'm probably the only one who is working on a product that needs support for fixed width over CSV.

I'm astonished by how quickly issues get responses in this repository. Keep up the amazing community support fellas.

jamesbascle commented 6 years ago

Correct me if I'm wrong Josh, but all someone needs to do in a contrib library for csvhelper is to implement another parser, no? Or is there an entire replacement of most of the API? I haven't looked at the excel libs but once or twice.

On Dec 28, 2017 5:14 PM, "Jason Harris" notifications@github.com wrote:

Thanks for the quick response. I've got the need to use fixed width alongside CSV reading/writing. It's a shame that fixed width is not in the library yet.. But I understand. I'm probably the only one who is working on a product that needs support for fixed width over CSV.

I'm astonished by how quickly issues get responses in this repository. Keep up the amazing community support fellas.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/JoshClose/CsvHelper/issues/886#issuecomment-354366270, or mute the thread https://github.com/notifications/unsubscribe-auth/AD_ohdKrmqOhYLblJ-mL6ajymlWOMocbks5tFBLQgaJpZM4ROrHl .

JoshClose commented 6 years ago

I believe they have a Reader/Writer that inherits CsvReader/CsvWriter, but I don't remember for sure.

As far as fixed width goes, you would need a FixedWidthParser that is used instead. You would also need to have some extra mapping or configuration so that you could specify the width of each column, the padding character, and maybe a few other things.

I think for CsvHelper to really be able to be built on top of, it would need to have things separated out a bit. There is a little bit too much CSV specific stuff in there. It would be nice to have more basic functionality that you build upon, and which there are CSV specific and fixed-width specific classes that inherit from the base functionality, so you don't have all the extra cruft from other implementations.