These are chat archives for nrinaudo/kantan.csv

15th
Feb 2017
Tomas Svarovsky
@fluke777
Feb 15 2017 20:41
Gents. Noob question here. Is it possible to change the escape character somehow? I need to tailor the output for specific tool that is not happy with the usual escape and quote character being the same.
Nicolas Rinaudo
@nrinaudo
Feb 15 2017 20:43
well, the "usual" escape and quote characters are the same, by specification :)
I'm pretty sure you cannot customise this (yet), but let me check
Tomas Svarovsky
@fluke777
Feb 15 2017 20:43
:-) If things were this easy in real life
the tool is Vertica by the way so it is not some small arcane tool :-)
thank you
Nicolas Rinaudo
@nrinaudo
Feb 15 2017 20:44
well, you can customise it, but it might be a pain.
Tomas Svarovsky
@fluke777
Feb 15 2017 20:45
got it. Do not worry about it then. I can get around it in another way but it would be great if this would be possible in the future if it does not compromise the design.
Nicolas Rinaudo
@nrinaudo
Feb 15 2017 20:45
no I mean it's possible, but it might be more work than you expect
kantan.csv generates CSV writers through WriterEngine - it'll pick whatever implicit value of that is in scope
Tomas Svarovsky
@fluke777
Feb 15 2017 20:45
ok. Is it documented somewhere?
to get me started?
Nicolas Rinaudo
@nrinaudo
Feb 15 2017 20:46
the default value, kantan.csv's internal writer, is good enough for most purposes, but not yours. So you need to provide a custom one, or use one of the existing non-default ones
I don't remember documentating that explicitly, no
but you can rip an existing instance - here, for example, the jackson module: https://github.com/nrinaudo/kantan.csv/blob/develop/jackson/src/main/scala/kantan/csv/engine/jackson/package.scala
Tomas Svarovsky
@fluke777
Feb 15 2017 20:47
just found it myself. Ok got it. Will try thank you
Nicolas Rinaudo
@nrinaudo
Feb 15 2017 20:48
I believe jackson lets you customise the escape character. So you should be able to modify the existing jackson implementation easily, for a flexible definition of easily
Tomas Svarovsky
@fluke777
Feb 15 2017 20:48
:-)
good enough I think
thanks again
Nicolas Rinaudo
@nrinaudo
Feb 15 2017 20:50
edit line 43 to add withQuoteChar('#'), import, run your code. Should work and use # for quoting
(let me know if you're struggling, I should be able to put something together for you)
Tomas Svarovsky
@fluke777
Feb 15 2017 20:52
thank you
Nicolas Rinaudo
@nrinaudo
Feb 15 2017 20:53
and there's really no reason for that not to be easier. I'll do something about this for the next release.
this lets you write:
implicit val writerEngine = writerFrom(s => JacksonCsv.defaultWriterSchema(s).withQuoteChar('#'))
and you're done.
I'm happy to release a SNAPSHOT build within a couple of hours if you find this useful
(I also need to do this for the other connectors before a full release)
Tomas Svarovsky
@fluke777
Feb 15 2017 21:47
@nrinaudo This is very helpful. No rush. One thing I am still grappling with. The jackson engine is not used by default. It uses the internal engine. So this hinges on using the jackson one?
Nicolas Rinaudo
@nrinaudo
Feb 15 2017 21:48
yes, you need to change the default engine. But the line of code I pasted above is the entirety of the modification you need to bring to your code
(you'll also need to update your build.sbt to depend on kantan.csv-jackson)
Tomas Svarovsky
@fluke777
Feb 15 2017 21:49
yes I get that. This would be awesome.
Nicolas Rinaudo
@nrinaudo
Feb 15 2017 21:49
I can also make the same modifications for the commons and open-csv modules (I'm doing that right now)
but the internal engine might be slightly trickier, so I need to give this part more thoughts
Tomas Svarovsky
@fluke777
Feb 15 2017 21:51
yeah. No worries. I have a workaround for now so no pressure. Would love to use this in the end since it is much cleaner + i like kantan
Nicolas Rinaudo
@nrinaudo
Feb 15 2017 21:51
glad you like kantan.csv, feel free to checkout kantan.xpath and kantan.regex :)
Tomas Svarovsky
@fluke777
Feb 15 2017 21:51
:-)
Nicolas Rinaudo
@nrinaudo
Feb 15 2017 21:52
I should have the external connectors done today. I might be able to do the internal one by the end of the week, and I need to put a new release together soon anyway
so you might actually get all that by the end of the week - and if you're fine with depending on SNAPSHOT artifacts for a while, tonight
this is actually something that I meant to do for ages, so thanks for giving me the nudge I needed!
Tomas Svarovsky
@fluke777
Feb 15 2017 21:54
:-) glad I could be of help. Yes, snapshot is fine for me. But again no pressure. Take your time.
Appreciate your work on this.
Nicolas Rinaudo
@nrinaudo
Feb 15 2017 21:54
external modules are pretty straightforward, and the tests already exist, so it's really not a problem
Nicolas Rinaudo
@nrinaudo
Feb 15 2017 22:01
alright, done. CI is running and if everything passes, I'll release SNAPSHOT artifacts within the hour
Tomas Svarovsky
@fluke777
Feb 15 2017 22:01
nice
Nicolas Rinaudo
@nrinaudo
Feb 15 2017 22:01
I do my best :)
Nicolas Rinaudo
@nrinaudo
Feb 15 2017 22:20
@fluke777 0.1.18-SNAPSHOT for 2.10, 2.11 and 2.12 are being uploaded as I type this
you'll need to add the sonatype SNAPSHOT repo to your build.sbt, though:
resolvers := Seq(
  Resolver.sonatypeRepo("releases"),
  Resolver.sonatypeRepo("snapshots")
)