Menu

Tree [d0c710] master release-2.0.1 /
 History

HTTPS access


File Date Author Commit
 src 2016-06-14 Clark Allen Clark Allen [4b0e13] Fixing code errors.
 .gitignore 2016-05-20 Clark Allen Clark Allen [ee93ed] Changes to README.txt
 README.txt 2016-06-14 Clark Allen Clark Allen [d0c710] Updating the README.txt file.
 build.sbt 2016-06-14 Clark Allen Clark Allen [cc3d4d] Fixing version information.

Read Me

Overview
===============================================================================

csvscalpar is a csv file parser written in Scala for Scala developers.  This
api was written to conform with RFC-4180.  Although RFC-4180 does not define
a standard, it is a request for comment and is perhaps the beginning of a
standard for the csv file format.

See :  https://tools.ietf.org/html/rfc4180



Fix in version 2.0.1
====================

Version 2.0.1 fixes a potential resource leak in the reader classes 
by ensuring that the file resources are closed after parsing.



New features in version 2.0.0
=============================

CsvFileReader and CsvLineReader have been augmented with methods that return
results in a Vector[Vector[String]] so that the user can benefit from that
immutable container with random access to its elements.  I have also added
flavors of the parsing methods that produce Option[List[List[String]]] and
Option[Vector[Vector[String]]] so that the user can chose to check for results
instead of catching exceptions.  The user now has a choice how to handle error
conditions when parsing a CSV file; Exceptions or Options.

I have added an emitter to the library so that the user can start with either
List[List[String]] or Vector[Vector[String]] and generate a CSV file from
either of those types of containers.


There are three classes of interest for the Scala programmer.

1. CsvFileReader reads an input file into memory all at once and then
   parses the file.

2. CsvLineReader reads an input file in chunks and processes the buffered input.
   CsvLineReader is slower, but is intended to be easier on memory than
   CsvFileReader.

3. CsvEmitter writes either a  Vector[Vector[String]]  or a  List[List[String]]
   as a csv file while handling embedded quotes and embedded field delimiters.

Using these classes is as simple as this :

  val reader = new CsvFileReader
  // The call below returns  Vector[Vector[String]]  or throws an exception on
  // failure.
  val result = reader.readCsvFileRand("path-and-file-name.csv", false, ",")

  // The call below returns  Option[Vector[Vector[String]]]
  val result = reader.readCsvFileROpt("path-and-file-name.csv", false, ",")

or use the line reader class...

  val reader = new CsvLineReader
  // The call below returns  Vector[Vector[String]]  or throws an exception on
  // failure.
  val result = reader.readCsvFile("path-and-file-name.csv", false, ",")

  // The call below returns  Option[Vector[Vector[String]]]
  val result = reader.readCsvFileROpt("path-and-file-name.csv", false, ",")


The principle methods of interest for the two reader classes have the same
signature.


The CsvEmitter class is similarly easy to use.

  val emitter = new CsvEmitter
  // call emit with :
  //    1. fieldList  is  either Vector[Vector[String]]  or List[List[String]]
  //    2. file_path_and_name.csv  is a String
  //    3. delim  is a String representation of the field delimiter you want to
  //       use.  You can use Defs.delim (it is just ",") as your default
  //       choice if you like.
  //    4. lineEnd  is a String representing the line ending sequence you would
  //       like to use.  You can use constants defined in the Defs class to
  //       help.
  //           Defs.ls  is a unix/linux line ending character
  //           Defs.crlf  is a Window line ending sequence
  //           Defs.lineEnd  is the line ending sequence used on your current platform

  val lines = emitter.emit(fieldList, file_path_and_name.csv, delim, lineEnd)


If you find bugs in this software or have a suggestion for an enhancement,
please email me and attach sample files that exhibit the behavior you observe.
Please be specific and clear in your wording.  English is full of ambiguity.


This software is released under the Apache 2 license, version 2.0.

   Copyright 2016 Clark Allen

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.