Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fast C library for reading CSV and other tabular text formats
C Python
tag: v0.3.2

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src
test
.gitignore
LICENSE
Makefile
README.md

README.md

Sheets

Sheets is a simple and fast C library for reading tabular text formats, such as CSV and TSV.

Features

  • Quoted fields

  • Escaped characters

  • Simple API

  • Zero dependencies

  • Liberal license

Usage

file = fopen("example.csv", "rb");

reader = sheets_read_file(file, &sheets_csv);
record = sheets_record_alloc(&sheets_csv);

while (sheets_reader_read(reader, record) == 0) {
    for (unsigned i = 0; i < sheets_record_size(record); i++) {
        sheets_record_field(record, i, &field);
        puts(field.value);
    }
}

Sheets reads data in ASCII-compatible encoding, such as UTF-8, from a buffer or file. The record separator may be either CR, LF or CRLF, and the field delimiter may be any ASCII character except CR or LF.

Sheets supports two methods of embedding field delimiters and record separators into fields: quoting and escaping. When quoting, a field containing a field delimiter, record separator or quote character must be enclosed within quote characters. Additionally, a quote character within a field must be escaped with another quote character. When escaping, any character preceded by the escape character is interpreted literally. The quote character or escape character may be any ASCII character except the field delimiter, CR or LF.

Given the field delimiter is set to , and the quote character to ", Sheets reads data that is in compliance with RFC 4180. Given the field delimiter is set to HT and quoting and escaping are disabled, Sheets reads data that is in compliance with the text/tab-separated-values MIME type.

See src/sheets.h for reference documentation.

Installation

Include src/sheets.c and src/sheets.h into your application.

History

  • 0.3.2 (2014-05-07)

    • Enables '-Wswitch-default' and '-Wswitch-enum' warnings
  • 0.3.1 (2012-04-28)

    • Fixes handling of empty records
  • 0.3.0 (2012-04-21)

    • Adds error constants
  • 0.2.0 (2012-04-18)

    • Adds escaped characters
  • 0.1.0 (2012-04-18)

    • Initial release

License

Sheets is released under the MIT License. See LICENSE for details.

Something went wrong with that request. Please try again.