import scala.io.Source
class CSVReader[A] {
def parse(path: String) = ReaderWithFile[A](path)
case class ReaderWithFile[A](path: String) {
def using(cfg: CSVParserConfig): Seq[A] = {
val lines = Source.fromFile(path).getLines().mkString("\n")
println(lines) // line 1
println(cfg) // line 2
null
}
}
object ReaderWithFile {
implicit def parser2parsed[A](parser: ReaderWithFile[A]): Seq[A] = parser.using(defaultParserCfg)
}
}
object CSVReader extends App {
def parser[A] = new CSVReader[A]
val myParser = parser
import myParser.ReaderWithFile.parser2parsed // line 3, IDE says that this import is unused!
myParser parse "csv-parser/test.csv" // expecting line 1 and 2 getting printed, but not!
// but this works
myParser parse "csv-parser/test.csv" using CSVParserConfig()
}
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
myParser parse "csv-parser/test.csv"
myParser parse "/Users/jothi/Projects/Private/scala-projects/csv-parser/test.csv"
// but this works
myParser parse "/Users/jothi/Projects/Private/scala-projects/csv-parser/test.csv" using CSVParserConfig(Pipe)
implicit def parser2parsed[B](parser: ReaderWithFile[B]): Seq[B] = parser.using(defaultParserCfg)