CSV application support

The comma-separated values file format is a very simple data file format that is supported by almost all spreadsheet software such as Excel (although Excel uses the list separator of the current locale settings, which is a semicolon instead of a comma for many locales), OpenOffice.org Calc and Gnumeric as well as many online spreadsheet services such as EditGrid and Google Docs & Spreadsheets. Many database management systems support the reading and writing of CSV files.

Programming language tools

Any programming language that has input/output and string processing functionality is capable of reading and writing CSV files. The following is a list of individual programming language support for the comma-separated values format.

Language

Tool

Notes

BASIC

none required

supported internally

C

Free Tools: CSV module,

bcsv,
CSV reading and manipulation
Libraries:

No comments in code. separated documentation.


Well documented, includes a CSV BNF grammar.

Cocoa/Objective-C

cCSVparse by Michael Stapelberg

BSD-licensed CSV parsing class

Haskell

http://www.xoltar.org/languages/haskell/CSV.hs

Not sure if RFC compliant.

Java

Several free CSV tools exist: Super CSV Sophisticated reading, writing (automatic conversion of data into type, automatic constraint checker).

QN CSV

CSVReader/Writer

CSVFile

ostermiller

OpenCSV

1

2

and commercial tools: Ricebridge Java CSV Component.

There are also JDBC drivers available: 3 4 5 6 and an ODBC driver: 7

 

Javascript

None. Use Javascript's split function for now (e.g. implement your own CSV parser).

Anyone find third party libraries for this? Would be nice to parse CSV returned as an XmlHttpRequest response. Though with MS environment, can mix Javascript code with VBScript libraries (mentioned in this table) to do the job.

LaTeX

csvtools

from CTAN

LISP

fare-csv, csv-parser

fare-csv is an ASDF package, csv-parser is a .lisp file

Mathematica

 

 

MATLAB

csvread, dlmread.

In the standard library.

.Net

FileHelpers - An Automatic File Import/Export Framework by Marcos Meli (LGPL) Blog

Fast CSV Reader by Sébastien Lorion. Open Source class (MIT licence).

CSV Reader

GemBox.Spreadsheet by GemBox Software for CSV <==> XLS <==> XLSX conversion.

TFieldedText Reads and writes CSV files using Fielded Text. (Public domain licence)

 

OCaml

OCaml CSV

Col: conversion between lists of records and CSV files with header (Camlp4 syntax extension)

 

Perl

Text::CSV_XS, Text::CSV_PP, or using a Perl DBI interface: DBD::CSV, DBD::AnyData, csvdiff - compare two csv-files

from CPAN

Perl

The first published formal Perl CSV specification.

not from CPAN

PHP

fgetcsv() function, fputcsv() function

In the standard library.

Python

Python CSV module

In the standard library.

R

read.csv

In the standard library.

Ruby

Ruby CSV module, or FasterCSV by James Gray

In the standard library.

Ruby on Rails framework

Convertible to csv

as an add-on (gem or plugin) .

Scheme

Chicken Scheme CSV module

Visual Basic or VBScript

ParseCSV Parse Csv File... ( Vbscript )

Data Interpretation

Many applications that import CSV will try to interpret numbers and dates in order to allow sorting or other formatting features. For example, if a CSV field contains a large integer such as 1234567890123456 then it will appear in Gnumeric as 1.2346789012346E+15 and the resulting value is less accurate. Some applications also accept a single quote-character at the beginning of numbers as a way to indicate that it should be displayed as text (typically left aligned while numbers are right aligned).

Utilities

The csvprint utility will reformat CSV input based on a format string. This can be useful for reordering fields or generating source code or tables as illustrated in the following example:

 $ csvprint data.csv "\t{ %0, %1, %2, \"%3\" },\n"
         { 0xC0000008, 0x00060001, NT_STATUS_INVALID_HANDLE, "The handle is invalid." },

csvdiff is a perl script to compare/diff two (comma) separated files with each other. The part that is different to standard diff is, that you'll get the number of the record where the difference occours and the field/column which is different. The separator can be set to the value you want it to, not just comma. Also you can to provide a third file which contains the columnnames in one(!) line separated by your separator. If you do so, columnnames are shown if a difference is found. Example:

$ perl csvdiff.pl -a act.csv -e exp.csv -s ";" -c col_names.csv -k "2" -t -i
Record with key "200100500" is different:
 Actual   line 006 > 200100500;200100500;6;;;;;;000;0;2005-12-20;55 <
 Expected line 008 > 200100500;200100500;6;;;;;;000;0;2005-12-19;55 <
  Difference in field no.: 11 - field name: Dat_Rueckgabe
   Actual   > 2005-12-20 <
   Expected > 2005-12-19 <

FTEditor is a Fielded Text editor which lets you view the contents of a CSV file simultaneously in an edit and grid window. As the text is modified in the edit window, the grid is interactively updated in the grid window with color highlighting showing corresponding data fields in each view. FTEditor uses Fielded Text to determine the structure of the CSV file. FTEditor can also interactively create and modify Fielded Text Meta files.