• Stars
    star
    346
  • Rank 117,813 (Top 3 %)
  • Language
    Scala
  • License
    Apache License 2.0
  • Created almost 9 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

CSV handling library for Scala

kantan.csv

Build Status Maven Central Join the chat at https://gitter.im/nrinaudo/kantan.csv

CSV is an unfortunate part of life. This attempts to alleviate the pain somewhat by letting developers treat CSV data as a simple iterator.

As much as possible, kantan.csv attempts to present a purely functional and safe interface to users. I've not hesitated to violate these principles internally however, when it afforded better performances. This approach appears to be somewhat successful.

Documentation and tutorials are available on the companion site, but for those looking for a few quick examples:

import java.io.File
import kantan.csv._         // All kantan.csv types.
import kantan.csv.ops._     // Enriches types with useful methods.
import kantan.csv.generic._ // Automatic derivation of codecs.

// Reading from a file: returns an iterator-like structure on (Int, Int)
new File("points.csv").asCsvReader[(Int, Int)](rfc)

// "Complex" types derivation: the second column is either an int, or a string that might be empty.
new File("dodgy.csv").asCsvReader[(Int, Either[Int, Option[String]])](rfc)

case class Point2D(x: Int, y: Int)

// Parsing the content of a remote URL as a List[Point2D].
new java.net.URL("http://someserver.com/points.csv").readCsv[List, Point2D](rfc.withHeader)

// Writing to a CSV file.
new File("output.csv").asCsvWriter[Point2D](rfc)
  .write(Point2D(0, 1))
  .write(Point2D(2, 3))
  .close()

// Writing a collection to a CSV file
new File("output.csv").writeCsv[Point2D](List(Point2D(0, 1), Point2D(2, 3)), rfc)

kantan.csv is distributed under the Apache 2.0 License.

More Repositories

1

scala-best-practices

Collection of best practices for the Scala programming language
CSS
231
star
2

kantan.xpath

XPath wrapper for Scala
Scala
56
star
3

kantan.regex

Regular expression library for Scala
Scala
24
star
4

kantan.dtables

Scala
17
star
5

talk-scala-best-practices

Talk on Scala best practices
HTML
12
star
6

kantan.codecs

Generic encoders / decoders for the various kantan libraries.
Scala
10
star
7

kantan.parsers

Scala
9
star
8

fetch

Scala HTTP client library
Scala
8
star
9

kantan.dot

Scala
7
star
10

nrinaudo.github.com

CSS
5
star
11

workshop-finch

Finch introduction workshop
HTML
5
star
12

far-more-adt

Slides for a talk on ADTs and GADTs
HTML
5
star
13

kantan.mongodb

Sane MongoDB library for Scala
Scala
4
star
14

dsl-tagless

HTML
4
star
15

pbt-functions

Demonsrates shrinking and showing of arbitrary functions
Scala
3
star
16

type-classes-from-the-ground-up

Slides for a talk on typeclasses, using CSV as a running example
HTML
3
star
17

kantan.repl

Scala
2
star
18

kantan.sbt

Support SBT plugin for kantan libraries
Scala
2
star
19

sbt-glpages

SBT autoplugin for publishing documentation to Gitlab Pages
Scala
2
star
20

optics-from-the-ground-up

Slides for a talk on optics
HTML
2
star
21

playground

Somewhere for me to store all my exploratory code
Scala
2
star
22

shrinking-showing-functions

Slides for my "Shrinking and showing functions (in Scala)" talk
HTML
1
star
23

much-ado-about-testing

Slides of my "much ado about testing" presentation
HTML
1
star
24

function-reuse

HTML
1
star
25

workshop-minimum-git

Workshop intended to teach what I think the minimum git knowledge should be
1
star
26

recursion-schemes-from-the-ground-up

HTML
1
star