What is CSV?

CSV stands for comma separated values. It is a spreadsheet format where each column is separated by a comma and each row by a newline. Here is an example CSV file:

    John,48,United States

You can download this file and view it in Excel, Google Docs, or even directly in a text editor. This same data saved in Excel format uses 4591 bytes and is supported by less applications.

A CSV file can be imported into a database or parsed with a programming language. This flexibility makes CSV the most common output format requested by clients for their scraped data.

Here is an example showing how to parse a CSV file with Python:

import csv
filename = 'example.csv'
reader = csv.reader(open(filename))
for row in reader:
    # display the value at the last column in this row
    print row[-1] 

blog comments powered by Disqus