These are chat archives for nrinaudo/kantan.csv

23rd
Sep 2017
olivetechnologies
@olivetechnologies
Sep 23 2017 15:51
Hello, nrinaudo
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 16:04
Hello @olivetechnologies . If this is regarding your Eclipse question, here might not be a bad place to ask, although the answer will need to come from other users. I have no clue regarding Eclispe
olivetechnologies
@olivetechnologies
Sep 23 2017 16:19
Lol, It is not about eclipse
It is about Kantan
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 16:19
did you work that out then?
olivetechnologies
@olivetechnologies
Sep 23 2017 16:19
yes, i did thanks
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 16:19
yeah I mean sorry, the kantan.csv issue you're having with Eclipse
good to hear
olivetechnologies
@olivetechnologies
Sep 23 2017 16:19
i now use scalafx for gui
Yes
i did
I am having an issue using asCsvReader to read a csv file
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 16:24
alright. Can you describe your issue, and maybe show some sample code that fails?
olivetechnologies
@olivetechnologies
Sep 23 2017 16:26
I am having error " value asCsvReader is not a member of URL"
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 16:27
You're lacking an import. Are you sure you used the same imports as in the documentation?
olivetechnologies
@olivetechnologies
Sep 23 2017 16:28
yes
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 16:28
alright. can you paste some code?
(word of warning: I'm 99% confident that the doc says to import kantan.csv.ops._ and you don't)
olivetechnologies
@olivetechnologies
Sep 23 2017 16:28
i did
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 16:29
alright, paste the code then, I'll see whether I can debug it
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 16:35
I might need to log off in a bit, so don't worry if I don't answer straight away
olivetechnologies
@olivetechnologies
Sep 23 2017 16:36
I am finding it difficult to copy and paste in here
I am quite new to gitter
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 16:36
feel free to put a link to scastie or a gist
no worries, I quite understand
olivetechnologies
@olivetechnologies
Sep 23 2017 16:37
If i retype the code i may not present the issues as it is on my file
'''
olivetechnologies
@olivetechnologies
Sep 23 2017 16:51

'''

import java.io.File
import scala.io.Source.
import scala.collection.mutable.StringBuilder.

import scala.math.
import kantan.csv.

import kantan.csv.ops.
import kantan.csv.generic.

import shapeless.Data.deriveHNil

object CreditCard {
val rawData = getClass.getResource("creditcard.csv")

val creditCardData = rawData.asCsvReader[(Int, List[Either[Int, Option[Double]]])]
'''

hello
'''

'''

import java.io.File
import scala.io.Source.
import scala.collection.mutable.StringBuilder.

import scala.math.
import kantan.csv.

import kantan.csv.ops.
import kantan.csv.generic.

import shapeless.Data.deriveHNil

object CreditCard {

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

val creditCardData = rawData.asCsvReader[(Int, List[Either[Int, Option[Double]]])]
'''

olivetechnologies
@olivetechnologies
Sep 23 2017 16:56
I hope presents my case enough for you
I need to say that there is an underscore at the end of each import statement
Though it is not showing here
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 17:15
You should use backticks rather than ticks for your code to display properly
olivetechnologies
@olivetechnologies
Sep 23 2017 17:30
Okay
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 19:28
So, this is a bit of a mess. Is the following the code I'm supposed to be looking at?
import java.io.File
import scala.io.Source._
import scala.collection.mutable.StringBuilder._
import scala.math._
import kantan.csv._
import kantan.csv.ops._
import kantan.csv.generic._
import shapeless.Data.deriveHNil
object CreditCard {
  val rawData = getClass.getResource("creditcard.csv")
  val creditCardData = rawData.asCsvReader[(Int, List[Either[Int, Option[Double]]])]
}
there's various things wrong in there. You have way too many imports, most of them useless, for instance
but the specific problem you asked help with is that asCsvReader takes a CsvConfiguration value, which you're not passing
something like this:
import kantan.csv._
import kantan.csv.ops._

object CreditCard {
  val rawData = getClass.getResource("creditcard.csv")
  val creditCardData = rawData.asCsvReader[(Int, List[Either[Int, Option[Double]]])](rfc)
}
(although I must say that's one weird row type you're declaring)
olivetechnologies
@olivetechnologies
Sep 23 2017 20:04
Thanks
i know my de\claration may not be right but the error it is giving is quite strange to me
olivetechnologies
@olivetechnologies
Sep 23 2017 20:16
Thanks
olivetechnologies
@olivetechnologies
Sep 23 2017 20:22
The declaration of the row implies that the first column is an Int, while the remaining column is either an Int or a Double
That is what i meant by the declaration
I just copied this code
'''
"1,2,3\n4,5,6".readCsvList, List[Int]
'''
from github to my file and am still having the same error
olivetechnologies
@olivetechnologies
Sep 23 2017 20:29
'''
"1,2,3\n4,5,6".asCsvReader[List[Int]](rfc).toList
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 20:37
yes, that type is saying each row is a List[Int]. Your type is saying, each row is an Int followed by by a list of things that are either an Int or a Double or absent
olivetechnologies
@olivetechnologies
Sep 23 2017 20:38
okay
So, i just want to understand what is wrong with it
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 20:40
it just seems very complex. Are you expecting arbitrary numbers of columns, or 2 columns for each row?
olivetechnologies
@olivetechnologies
Sep 23 2017 20:41
it just seems very complex. Are you expecting arbitrary numbers of columns, or 2 columns for each row? I am only expecting an Int or Double
I guess the first Int shouldn't have been there
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 20:42
so each row is exactly one column?
olivetechnologies
@olivetechnologies
Sep 23 2017 20:43
No. about 32 columns but either Int or Double
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 20:44
right, so List[Either[Int, Double]] then
olivetechnologies
@olivetechnologies
Sep 23 2017 20:44
Yes, i thought as much
also the error still persists
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 20:46
could you then give me:
  • clean, reproducible code
  • the actual error
    ?
olivetechnologies
@olivetechnologies
Sep 23 2017 20:46
Okay
olivetechnologies
@olivetechnologies
Sep 23 2017 20:53
import kantan.csv._
import kantan.csv.ops._


object card2 {

val rawData = getClass.getResource("creditcard.csv")
val creditCardData = rawData.asCsvReader[Either[Int,Double]](rfc)

}
The error is "value asCsvReader is not a member of java.net.URL
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 20:55
then I'm afraid you're not compiling the code you're showing me, one way or another (maybe Eclipse is still playing silly bugger?)
olivetechnologies
@olivetechnologies
Sep 23 2017 20:56
okay
I will load the file and get back to you
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 20:57
the code you pasted doesn't compile either, but for a different reason. It fails to compile because you're using Either[Int, Double] when we just said you should be using List[Either[Int, Double]]
olivetechnologies
@olivetechnologies
Sep 23 2017 20:58
The error still persists
I just did the editing
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 20:59
sorry, I wasn't clear. The specific error you're talking about is proof that you're not showing me the right code. I'm just saying that the code you're showing has other, additional errors
so maybe you're not depending on the right version of kantan.csv, maybe Eclipse doesn't work, maybe you're copying the wrong code?
olivetechnologies
@olivetechnologies
Sep 23 2017 21:00
import kantan.csv._
import kantan.csv.ops._


object card2 {

val rawData = getClass.getResource("creditcard.csv")
val creditCardData = rawData.asCsvReader[List[Either[Int,Double]]](rfc)

}
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 21:00
but whatever the reason, the code you pasted doesn't have any issue with finding asCsvReader
that compiles just fine
if it doesn't on your computer, it's either because you're not showing me the code you're attempting to compile, or because of other factors, such as Eclipse being a mess
olivetechnologies
@olivetechnologies
Sep 23 2017 21:03
Do you think intelliJ will do better?
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 21:04
IntelliJ has some issues, but I don't think dependency management is one of them
olivetechnologies
@olivetechnologies
Sep 23 2017 21:04
Okay
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 21:04
but you don't need an IDE to compile though. Just run sbt
olivetechnologies
@olivetechnologies
Sep 23 2017 21:04
Okay
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 21:05
if you're trying to compile that code through Eclipse and not through sbt, it's entirely possible that your issue is simply one of IDE configuration. That's something you should take to the IDE's maintainers
olivetechnologies
@olivetechnologies
Sep 23 2017 21:05
Okay
I am using Eclipse though
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 21:06
in general, when you have issues, try to compile them the normal way - through a proper project, with a proper build tool (I favour SBT, although there are alternatives). IDEs are world of their own.
well, as I said, I can't help with Eclipse. Don't know it, don't plan on learning it or ever using it. Your issue is not with kantan.csv, but with Eclipse.
olivetechnologies
@olivetechnologies
Sep 23 2017 21:08
Okay
Thanks
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 21:08
sure, you're welcome
olivetechnologies
@olivetechnologies
Sep 23 2017 21:08
Am i the first person to bring this to your notice?
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 21:09
yes, since this is not a kantan.csv problem
olivetechnologies
@olivetechnologies
Sep 23 2017 21:10
Okay
I will report it at eclipse chat room
Nicolas Rinaudo
@nrinaudo
Sep 23 2017 21:10
good luck!