These are chat archives for nrinaudo/kantan.csv

28th
Jan 2017
Carlos Quiroz
@cquiroz
Jan 28 2017 02:32
Hi should I be able to encode this case class?
case class SourcePointRow(p: Point, l: List[Tech])
I have encoders for the Point and Tech classes
But I get an error with
could not find implicit value for parameter ea: kantan.csv.RowEncoder[SourcePointRow]
I’m using the generic module
What I expect as the csv output is a variable length output
Carlos Quiroz
@cquiroz
Jan 28 2017 02:54
Can I instead write my own encoder?
It seems that the variable length causes troubles
Nicolas Rinaudo
@nrinaudo
Jan 28 2017 08:00
I'm having a complicated day, but I'll try and answer these questions as soon as I get some free time. @cquiroz , you need to write a custom RowEncoder, I can show you how - or I'm sure @aroberts knows how by now :)
Nicolas Rinaudo
@nrinaudo
Jan 28 2017 13:46
@cquiroz thanks for the PR! it needs to be done onto develop rather than master (you couldn't guess, I failed to include a CONTRIBUTING file, my fault entirely).
By default I'm letting you deal with that, as it's your PR, but I'm fine with doing it myself and merging afterwards. Whatever works for you
@fluke777 glad you managed to find what you were looking for. Let me know anything else trips you up!
@cquiroz this is off the cuff (I need to get going soon) but should compile:
implicit val encoder: RowEncoder[SourcePointRow] = RowEncoder.from(s =>
  RowEncoder[Point].encode(s.p) ++ s.l.flatMap(RowEncoder[Tech].encode)
)
the concept is that you use your existing Point and Tech encoders and concatenate the results. I'm not sure how usable the output CSV file will be - how do you know where one Tech ends and the other starts? but I assume you have a plan
Carlos Quiroz
@cquiroz
Jan 28 2017 14:30
@nrinaudo You’re right, the output won’t be good. I’ll change it to be somehow fixed in columns
Nicolas Rinaudo
@nrinaudo
Jan 28 2017 16:26
if you could show me your Point and and Tech case classes, I might be able to make suggestions
but yeah, while variable length CSV files are perfectly ok to write, they can be more of a pain to read
I mean I'm sure we could put a RowDecoder instance together - it wouldn't be pretty, but I don't see why we couldn't get it to work - but if you're going in that direction, I think maybe CSV is not the right serialisation format for your use case
JSON or XML seem like a better fit
Nicolas Rinaudo
@nrinaudo
Jan 28 2017 16:32
@cquiroz oh, and thanks for the PR, it's now merged :)
Carlos Quiroz
@cquiroz
Jan 28 2017 17:15
@nrinaudo Yes the more I think about it, the less enthusiastic about variable length I'm
I’d rather stick to the max length and keep blanks if needed
Nicolas Rinaudo
@nrinaudo
Jan 28 2017 18:40
Alright. Let me know if you get stuck, maybe I can help
Carlos Quiroz
@cquiroz
Jan 28 2017 18:56
how could I represent a blank? with Option?
Nicolas Rinaudo
@nrinaudo
Jan 28 2017 18:57
Right
And if you have an encoder or decoder for A, you also do for Option[A]
If you want to share some code I'd be happy to look at it tonight and suggest inprovements
Nicolas Rinaudo
@nrinaudo
Jan 28 2017 21:06
@/all releasing 0.1.17 as I type this. Lots of small bug fixes / improvements, the main new feature being BOM handling for the unfortunate among you that have to deal with Excel.
Carlos Quiroz
@cquiroz
Jan 28 2017 21:08
Great! is there a changelog?
Nicolas Rinaudo
@nrinaudo
Jan 28 2017 21:08
erm...
No. I suck.
Carlos Quiroz
@cquiroz
Jan 28 2017 21:09
:D Don’t worry...
Nicolas Rinaudo
@nrinaudo
Jan 28 2017 21:09
no but you're right, of course, I should maintain a proper changelog
it's just, you know... time :)
it's hard to find the time to maintain the kantan libraries, let alone do it properly