The CSV Format

It’s for good reason that the example file we started with was the humble TSV file. It’s probably the simplest sort of delimited data we’re likely to encounter. However, the most common format by far is the comma-separated values (CSV) file. It is, for better or for worse, the standard file format for exporting data from and importing data to websites, databases, spreadsheets, and pretty much any other data store. If you haven’t encountered CSV files in your development so far, you’re virtually guaranteed to at some point.

Initially, it might seem like a simple proposition to parse CSV files. You might think that you can set your field separator to , rather than a tab character, and then generally proceed as you did for TSV files. ...

Get Text Processing with Ruby now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.