These are chat archives for nrinaudo/kantan.csv

28th
Sep 2017
olivetechnologies
@olivetechnologies
Sep 28 2017 15:08
Hello
@nrinaudo reading the file as a string using asCsvReader works fine
olivetechnologies
@olivetechnologies
Sep 28 2017 15:25
but as a case class i am having an error "Not enough argument for method asCsvReader"

import kantan.csv._
import kantan.csv.ops._
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 card2 {
  def main(args: Array[String]){

   val rawData = getClass.getResource("creditcard.csv")

   val creditCardDataCase = rawData1.asCsvReader[CardData](rfc.withoutHeader)


  }

}

import kantan.csv._
import kantan.csv.ops._
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 card2 {
  def main(args: Array[String]){

   val rawData = getClass.getResource("creditcard.csv")

   val creditCardDataCase = rawData.asCsvReader[CardData](rfc.withoutHeader)


  }

}
olivetechnologies
@olivetechnologies
Sep 28 2017 15:36
hello
Nicolas Rinaudo
@nrinaudo
Sep 28 2017 15:38
I'm really very confused by your reports. Why are there two different code snippets? Are they different?
olivetechnologies
@olivetechnologies
Sep 28 2017 15:44
There is a little difference, value rawData1 in creditCardDataCase declaration was not declared in the first snippet
That really is not the main issue in this case
I really do not understand the other parameters of asCsvReader that it is demanding.
Nicolas Rinaudo
@nrinaudo
Sep 28 2017 15:47
your code compiles for me
it's possible that you're using an old version of kantan.csv, where asCsvReader expected two parameters
so, conclusion: odds are, your problem is Eclipse again. I think it's about time you took a long, hard look at your toolchain
olivetechnologies
@olivetechnologies
Sep 28 2017 15:49
Okay
How do i include string in the list items in this code
val creditCardDataCase = rawData1.asCsvReader[List[Either[Int, Double]]](rfc)
so that the Objects in the list could either be String, Int or Double
Nicolas Rinaudo
@nrinaudo
Sep 28 2017 15:53
Either[String, Either[Int, Double]]
olivetechnologies
@olivetechnologies
Sep 28 2017 15:54
I have tried that it is saying Either could only take 2 inputs
Nicolas Rinaudo
@nrinaudo
Sep 28 2017 15:54
look at the type. I'm using two Either, each with 2 parameters
olivetechnologies
@olivetechnologies
Sep 28 2017 15:55
got it
Thanks
What enviroment are you using?
Nicolas Rinaudo
@nrinaudo
Sep 28 2017 15:56
SBT for building and Emacs as an editor
in your case, I'd suggest SBT for building and IntelliJ IDEA as an editor
olivetechnologies
@olivetechnologies
Sep 28 2017 15:57
I need help setting it up
Nicolas Rinaudo
@nrinaudo
Sep 28 2017 15:57
There's an SBT gitter channel to help you set SBT up, they're quite helpful
olivetechnologies
@olivetechnologies
Sep 28 2017 15:57
i have downloaded intelliJ IDEA
Nicolas Rinaudo
@nrinaudo
Sep 28 2017 15:57
as for IntelliJ, it can basically import an SBT project and set itself up
olivetechnologies
@olivetechnologies
Sep 28 2017 15:57
Okay
I have done all the setting up
It is just that it is lagging and can be frustrating
Nicolas Rinaudo
@nrinaudo
Sep 28 2017 15:59
Agreed. On the plus side: it actually works.
olivetechnologies
@olivetechnologies
Sep 28 2017 15:59
How can i handle the lagging?
Nicolas Rinaudo
@nrinaudo
Sep 28 2017 15:59
allocate more RAM, use a faster computer... I don't use IntelliJ so I can't really help you
olivetechnologies
@olivetechnologies
Sep 28 2017 16:00
Is there any tweaking that coul minimize it
Nicolas Rinaudo
@nrinaudo
Sep 28 2017 16:00
there might be. There might be an IntelliJ gitter channel where you can ask the question?
olivetechnologies
@olivetechnologies
Sep 28 2017 16:03
Okay
olivetechnologies
@olivetechnologies
Sep 28 2017 17:02
Hello
This code compiles fine
import kantan.csv._
import kantan.csv.ops._
import kantan.csv.generic._
import scala.io.Source._ 


object card2 {
  def main(args: Array[String]){
   val rawData = getClass.getResource("creditcard.csv")
   val rawData1 = fromFile("creditcard.csv").drop(1).mkString
   val creditCardData = rawData1.asCsvReader[List[Either[String, Either[Int, Double]]]](rfc)

   creditCardData.take(5).foreach(println)
  }

}
It prints out
Failure(TypeError: 'ime' is not a valid Double)
Success(List(Left(0), Right(-1.359807134), Right(-0.072781173), Right(2.536346738), Right(1.378155224), Right(-0.33832077), Right(0.462387778), Right(0.239598554), Right(0.098697901), Right(0.36378697), Right(0.090794172), Right(-0.551599533), Right(-0.617800856), Right(-0.991389847), Right(-0.311169354), Right(1.468176972), Right(-0.470400525), Right(0.207971242), Right(0.02579058), Right(0.40399296), Right(0.251412098), Right(-0.018306778), Right(0.277837576), Right(-0.11047391), Right(0.066928075), Right(0.128539358), Right(-0.189114844), Right(0.133558377), Right(-0.021053053), Right(149.62), Left(0)))
olivetechnologies
@olivetechnologies
Sep 28 2017 17:08
I guess it is not recognizing the String type in the list parameters of asCsvReader
Nicolas Rinaudo
@nrinaudo
Sep 28 2017 20:51
It'd help to have the data that produces the error
olivetechnologies
@olivetechnologies
Sep 28 2017 21:22
I somehow was able to set up intellij with Scala
All is working very fine now
But

Import kantan.csv.generic._ is showing an error
" generic is not a value of kantan.CSV
Nicolas Rinaudo
@nrinaudo
Sep 28 2017 21:26
I'm afraid that, again, this is your setup. You don't have he right dependencies configured. There is documentation written on how to set your build.sbt dependencies
If this is not enough, please learn to use your tools. I do not use IntelliJ or Eclipse, so maybe ask on these tools' channels?
olivetechnologies
@olivetechnologies
Sep 28 2017 21:46
and added the neccesary dependencies
while the code works perfectly for "decoding row as collections "
It does not work for "decoding row as case classes"
And the only different import statement is kantan.csv.generic._
olivetechnologies
@olivetechnologies
Sep 28 2017 21:52
Which it has consistently been indicated that generic is not part of kantan.csv._
and i guess that is the reason it is not working
I am just trying to bring your notice to this
Nicolas Rinaudo
@nrinaudo
Sep 28 2017 22:02
The code in the documentation is compiled, so it can't really not work. Your problem is that you haven't added the generic dependency, as documented in the corresponding documentation: http://nrinaudo.github.io/kantan.csv/tut/shapeless.html
olivetechnologies
@olivetechnologies
Sep 28 2017 22:14
okay
i got it