These are chat archives for nrinaudo/kantan.csv

25th
Sep 2017
olivetechnologies
@olivetechnologies
Sep 25 2017 13:59
hello
@nrinaudo
import kantan.csv._
import kantan.csv.ops._
import kantan.csv.codecs._
import kantan.csv.generic._

final case class CardData(Time: Int, V1: Double, V2: Double, V3: Double, V4: Double, V5: Double, V6: Double,
                    V7: Double, V8: Double,V9: Double,V10: Double,V11: Double,V12: Double, V13: Double, V14: Double,
                    V15: Double,V16: Double, V17: Double,V18: Double,V19: Double, V20: Double, V21: Double, V22: Double,
                    V23: Double,V24: Double, V25: Double, V26: Double, V27: Double, V28: Double, Amount:Double, Class: Int)

object CreditCards {

  def main(args: Array[String]): Unit = {

  val rawData = getClass.getResource("creditcard.csv")
  val creditCardData = rawData.asCsvReader[CardData](rfc.withHeader)

   creditCardData.take(2).foreach(println)
  }
}
Nicolas Rinaudo
@nrinaudo
Sep 25 2017 14:42
I'm not sure what you're asking, or if you're asking something
Long Cao
@longcao
Sep 25 2017 15:34
If I'm using generically derived decoding to case classes, is there a way for me to override the default decoding behavior of say, Option[T] decoding?
e.g.:
implicit def optDecoder[T : CellDecoder]: CellDecoder[Option[T]] = {
  CellDecoder.from { s =>
    if (invalidValues.contains(s))
      DecodeResult(None)
    else 
      implicitly[CellDecoder[T]].decode(s).map(Some(_))
  }
}
inserting a println somewhere in there and it doesn't appear like it's being called at all despite being in the closest possible implicit resolution scope
Nicolas Rinaudo
@nrinaudo
Sep 25 2017 15:35
I'm quite busy right now, but if no one helps by the time I get home tonight, I'll take a stab at answering that in 5 or 6 hours
Long Cao
@longcao
Sep 25 2017 15:36
@nrinaudo No problem, I have a feeling that it doesn't but thought it was worth throwing it out there if anyone else saw the same :)
olivetechnologies
@olivetechnologies
Sep 25 2017 15:50
@nrinaudo
I am having an io Error each time I try to run the above code
Nicolas Rinaudo
@nrinaudo
Sep 25 2017 15:52
@longcao there's no reason it shouldn't work, although there might be more elegant ways to achieving the same ends. Can you paste a complete reproduction that includes the code, the expected behaviour and the observed behaviour? Feel free to open an issue as well, if you feel it'll be easier to format than in gitter
olivetechnologies
@olivetechnologies
Sep 25 2017 15:52
The CSV file is already in my eclipse project directory
Long Cao
@longcao
Sep 25 2017 15:53
@nrinaudo I'd be happy to - perhaps later in the day I can put together a minimal example. maybe there's something I was missing as well
Nicolas Rinaudo
@nrinaudo
Sep 25 2017 15:53
@olivetechnologies I'll need more info, reproduction code, actual error, the usual. Also, Eclipse. My money is on the problem being Eclipse, because it usually is
@longcao in your case, it sounds like T is fixed - you have a list of invalid values that cannot be decoded as T. Why not write a CellDecoder[T] for that T and let implicit composition do your work for you?
(need to be off now, I'll take a look later)