These are chat archives for nrinaudo/kantan.csv

21st
Feb 2017
Andrew Roberts
@aroberts
Feb 21 2017 15:43
@nrinaudo - that would be good, I think. It’s also possible that there’s an implicit solution with asCsv that doesn’t make configuration too painful, but I don’t know enough about the subtlties of implicit ambiguity to know if it’s possible. That said, it does make me wonder if such subtlety in the argument space would be a good idea
Nicolas Rinaudo
@nrinaudo
Feb 21 2017 15:43
? :)
Andrew Roberts
@aroberts
Feb 21 2017 15:44
regarding that shapeless issue, I got nothing :\
Nicolas Rinaudo
@nrinaudo
Feb 21 2017 15:45
that's alright, I've actually worked it out (or at least somebody did and explained it to me)
the current status, which I expect to commit this week, is supposed to be backward compatible through deprecation. All methods that uses to take a column separator and header parameter now take a CsvConfiguration value
the default one, rfc, is available from importing kantan.csv._
so you can just write:
new File("my_file.csv").asCsvReader(rfc)
Andrew Roberts
@aroberts
Feb 21 2017 15:47
similarly for decoding?
Nicolas Rinaudo
@nrinaudo
Feb 21 2017 15:48
that was meant to be a decoding example, just fixed it :)
Andrew Roberts
@aroberts
Feb 21 2017 15:48
ah :)
Nicolas Rinaudo
@nrinaudo
Feb 21 2017 15:48
the old call, asCsvReader(',', true) still compiles, only with a deprecation warning
the idea is that CsvConfiguration scales a lot better as I add more features to the parser / serialiser
for instance, the upcoming release has first-party support for changing the quote character, as requested by @fluke777
this means that you don't have to write asCsvReader(',', '"', true). Everything is inside the CsvConfiguration value
Nicolas Rinaudo
@nrinaudo
Feb 21 2017 16:00
I realise this is not exactly earth shattering, but I was hoping for slightly more enthusiasm :)
Andrew Roberts
@aroberts
Feb 21 2017 16:03
I think it’s good :) nobody ever gets excited about configuration, it’s not sexy enough
actually, I think it’s particularly nice for juggling multiple formats, because then I can explicitly name them, and my code becomes that much clearer
Nicolas Rinaudo
@nrinaudo
Feb 21 2017 16:04
well, one of the advantages is that now, my enhancement operators should all have an arity of 1, which means that I should be able to use machinist for 0-cost enhancements
yeah, that's also the idea. new File("out.csv").writeCsv(excel, new File("in.csv").asCsvReader(rfc)), for example
I'm hoping to provide default configurations for most common variations - Excel, RFC, MySql, Oracle...
(of course, Excel is problematic in that I should also make charset part of CsvConfiguration, which is annoying)
Andrew Roberts
@aroberts
Feb 21 2017 16:11
excel :gun:
huh, never heard of machinist, I’ll look at that
Nicolas Rinaudo
@nrinaudo
Feb 21 2017 16:11
unfortunately the most used CSV reader out there
on one of my company's computers, somehow, Excel reads CSV in ISO-LATIN-1 but writes them in cp1252. Go debug that.
machinist provides macros for enhancement methods such as .asCsvReader. A bit like imp provides 0-cost instance summoning methods