Comma-separated_values Comma-separated_values

Comma-separated values - Definition and Overview

The comma-separated values (CSV) file format is a tabular data format that has fields separated by the comma character and quoted by the double quote character. If a field's value contains a double quote character it is escaped with a pair of double quote characters.

The CSV file format does not require a specific character encoding, byte order or line terminator format.

It is often not required by software to have fields quoted unless they contain a comma character.

Contents

Example

"Chicane", "Love on the Run", "Knight Rider", "This field contains a comma, but it doesn't matter as the field is quoted"
"Charles Barber", "Adagio for Strings", "Classical", "This field contains a double quote character, "", but it doesn't matter as it is escaped"

Application Support

The CSV file format is a very simple data file format that is supported by almost all spreadsheet software such as Excel (Careful: some local versions use semicolon instead of comma!) and Gnumeric. Any programming language that has input/output and string processing functionality will be able to read and write CSV files.

CSV is similar in ubiquity for tabular data as ASCII files are for text data.

Programming Language Tools

C/C++

Michael Allen's CSV module (http://www.ioplex.com/~miallen/libmba/dl/src/csv.c) is small, complete, and robust.

Perl

With DBI

CSV files can be accessed via SQL statements through DBI using a driver such as DBD::CSV (http://search.cpan.org/~jzucker/DBD-CSV-0.2002/lib/DBD/CSV.pm) or DBD::AnyData (http://search.cpan.org/~jzucker/DBD-AnyData-0.06/AnyData.pm).

With Regular Expressions

CSV files can be manipulated using Perl's built in text processing capabilites. For instance, the following code will convert a comma delimited data into colon delimited data.

perl -ne 'print join q(:),(split /,/,$_)' < input.csv > output.csv

Java

Direct Interface

CSVReader/Writer (http://mindprod.com/products.html#CSV) provides a simple Java interface to CSV file I/O and is free.

The Java CSV Library (http://sourceforge.net/projects/javacsv/) is an open-source (LGPL) currently in beta.

Stephen Ostermiller has released a library[1] (http://ostermiller.org/utils/ExcelCSV.html) under the GPL to read and write CSV for Excel.

This CSV class (http://www.ioplex.com/~miallen/CSV.txt) is small, complete, and has been widely used in production environments.

Ricebridge Java CSV Component (http://www.ricebridge.com/products/csvman.htm) is a commercial CSV interface for high-speed, high-volume data handling.

JDBC Interface

CsvJdbc (http://sourceforge.net/projects/csvjdbc/) is a read-only JDBC driver released under the LGPL.

StelsCSV (http://www.csv-jdbc.com/) is a commercial JDBC driver for CSV file databases. It supports much of SQL'92.

FOSITEX by i-net software also includes a CSV JDBC driver [2] (http://www.inetsoftware.de/English/produkte/FOSITEX/default.htm).

On Microsoft Windows one can access a CSV file through SQL using ODBC. See Using CSV Files as Databases and Interacting with Them Using Java (http://www.devarticles.com/c/a/Java/Using-CSV-Files-as-Databases-and-Interacting-with-Them-Using-Java/).

Python

Python has a csv module (http://www.python.org/doc/current/lib/module-csv.html) in the standard library since version 2.3.

Utilities

The csvprint (http://www.ioplex.com/~miallen/libmba/dl/examples/csvprint.c) 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." },

Example Usage of Comma-separated

owenp: @joannayoung thanks for the heads-up. I have ", and" at the end of a Comma-separated list on my bio. Should be no comma I think.
PowerGUIorg: PowerShell v2 tip: Export-CSV Converts Microsoft .NET Framework objects into a series of Comma-separated value (CSV) v... http://is.gd/58XfW
gtwitspace: Comma Separated Values (CSV) from Table Column http://bit.ly/6k6VBK
Copyright 2009 WordIQ.com - Privacy Policy  :: Terms of Use  :: Contact Us  :: About Us
This article is licensed under the GNU Free Documentation License. It uses material from the this Wikipedia article.