Giter VIP home page Giter VIP logo

Comments (9)

marklister avatar marklister commented on June 29, 2024

Yeah, it would be a logical thing to provide, and I've thought it through before, but I've not seen a way to preserve the types for a column. In other words you'd wind up with a Seq[Any] after retreiving the column by header.

If you can think of a way around this limitation I'd be keen to implement the feature.

from product-collections.

antonkulaga avatar antonkulaga commented on June 29, 2024

What about introducing a class that extends ColSeq and has val headers:Seq[String] and some extra methods?

from product-collections.

marklister avatar marklister commented on June 29, 2024

Yeah, that's easily doable... 
On 19 Apr 2015 10:41, Anton Kulaga [email protected] wrote:What about introducing a class that extends ColSeq and has val headers:Seq[String] and some extra methods?

—Reply to this email directly or view it on GitHub.

from product-collections.

marklister avatar marklister commented on June 29, 2024

Once again though if one wants to return a column the interface is going to have to be Map[String, Any]. I can probably do this in CollSeq not CollSeqN which makes things quite simple.

from product-collections.

marklister avatar marklister commented on June 29, 2024

I mean Seq[Any] of course...

from product-collections.

antonkulaga avatar antonkulaga commented on June 29, 2024

Yes, the issue is not simple. I think it can be discussed in gitter as I see several alternative ways to solve it

from product-collections.

marklister avatar marklister commented on June 29, 2024

Maybe tomorrow, I'm off to lunch shortly which in this country invariably involves the drinking of wine,..

from product-collections.

antonkulaga avatar antonkulaga commented on June 29, 2024

I do not like Seq[Any] I think we can get more by using case classes together with macro annotations. So, if you know the structure of csv file, then instead of ColSeq[String,String...ntype] you can create a case class. Here is a PR that does this #32

from product-collections.

marklister avatar marklister commented on June 29, 2024

I'm gonna separate this issue into two: Issue one deals with header support in CollSeq. I've put together a feature branch to deal with this branch: collseq-headers

The macro approach to a Seq of case classes #32 needs it own issue I think.

I've done some preliminary work on collseq-headers:

scala> val csv ="""a,b,c
     | 1,2,3
     | 4,5,6"""
csv: String =
a,b,c
1,2,3
4,5,6

scala> CsvParser[Int,Int,Int].parse(new java.io.StringReader(csv),hasHeader=true)
res0: com.github.marklister.collections.immutable.CollSeq3[Int,Int,Int] =
         a,b,c
CollSeq((1,2,3),
        (4,5,6))

scala> res0.collMap("b")
res1: Seq[Any] = List(2, 5)

scala> res0.collMap
res2: Map[String,Seq[Any]] = Map(a -> List(1, 4), b -> List(2, 5), c -> List(3, 6))

scala> res0.collMap("b")
res3: Seq[Any] = List(2, 5)

scala> res0.collMap("c")
res4: Seq[Any] = List(3, 6)

from product-collections.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.