csv-parser

Generic CSV parser library using Shapeless scala library

License

License

Categories

Categories

CSV Data Data Formats
GroupId

GroupId

com.bigelectrons.joesan
ArtifactId

ArtifactId

csv-parser_2.12
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

csv-parser
Generic CSV parser library using Shapeless scala library
Project URL

Project URL

https://github.com/joesan/csv-parser
Project Organization

Project Organization

com.bigelectrons.joesan
Source Code Management

Source Code Management

https://github.com/joesan/csv-parser

Download csv-parser_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/com.bigelectrons.joesan/csv-parser_2.12/ -->
<dependency>
    <groupId>com.bigelectrons.joesan</groupId>
    <artifactId>csv-parser_2.12</artifactId>
    <version>0.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.bigelectrons.joesan/csv-parser_2.12/
implementation 'com.bigelectrons.joesan:csv-parser_2.12:0.2.0'
// https://jarcasting.com/artifacts/com.bigelectrons.joesan/csv-parser_2.12/
implementation ("com.bigelectrons.joesan:csv-parser_2.12:0.2.0")
'com.bigelectrons.joesan:csv-parser_2.12:jar:0.2.0'
<dependency org="com.bigelectrons.joesan" name="csv-parser_2.12" rev="0.2.0">
  <artifact name="csv-parser_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.bigelectrons.joesan', module='csv-parser_2.12', version='0.2.0')
)
libraryDependencies += "com.bigelectrons.joesan" % "csv-parser_2.12" % "0.2.0"
[com.bigelectrons.joesan/csv-parser_2.12 "0.2.0"]

Dependencies

compile (5)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.4
joda-time : joda-time jar 2.7
com.chuusai : shapeless_2.12 jar 2.3.3
com.opencsv : opencsv jar 3.9
ch.qos.logback : logback-classic jar 1.2.3

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.12 jar 3.0.5

Project Modules

There are no modules declared in this project.

Codacy Badge Build Status Open Source

csv-parser Unit Tests

A parser implementation for CSV files using the awesome Shapeless library! Just parse any CSV file of your choice.

All you have to specify is a case class that you want the CSV to parse into and of course the CSV file that you want to parse. With this information, the library can produce a Sequence of your case classes. Any errors are being logged and possibly ignored!

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Pre-requisites

1. Install Java Version 8
2. Install Scala Version 2.12.7
3. Install SBT version 1.2.8
4. Install IntelliJ - Latest community edition and then install the latest Scala / SBT plugins available

Installing

Follow the steps below to import the project into IntelliJ

1. Clone the project from: 
   git clone https://github.com/joesan/csv-parser.git
   
2. Fire up IntelliJ and import the project
   
3. If you are opening IntelliJ for the first time, set up the Scala library in IntelliJ

Running tests

You have the option here to either run tests from IntelliJ or from the command line

To run tests from the command line, do the following:

1. Open a terminal and navigate to the project root folder 
   
2. Issue the following command:
   sbt clean test

To run any specific tests from within IntelliJ, simply right click the test that you wish you run and click Run

Using the parser

This application is built as a standalone jar and published to the OSS Sonatype repos. To add the parser as a dependency to your project's build.sbt:

libraryDependencies += "com.bigelectrons.csvparser" %% "csv-parser" % version

Latest version: Latest version

TODO: Documentation pending:

Once added as a dependency, you can use the parser as below:

case class MeterData(meterId: String, dateTime: DateTime, meterReadings: Seq[Double])

val canonicalName = Some(classOf[MeterData].getCanonicalName)
val meterCsvParserCfg = CSVParserConfig(withHeaders = true, caseClassCanonicalName = canonicalName, splitterFn = Some(meterDataSplitter))
val meterCsv = "/path/to/csv/file/meterdata.csv"
val csvParser = CsvParser.apply[MeterData]
val meterDataSeq: Seq[MeterData] = csvParser.parse(meterCsv, meterCsvParserCfg)

Built With

  • SBT - Scala Build Tool

Authors / Maintainers

License

Feel free to use it

Acknowledgments

Versions

Version
0.2.0