LinuxCommandLibrary

csvpy

Interactive Python shell for CSV files

TLDR

Open a CSV file in a Python shell

$ csvpy [data.csv]
copy
Open with tab delimiter
$ csvpy -t [data.tsv]
copy
Open with agate library loaded
$ csvpy --agate [data.csv]
copy
Open with custom encoding
$ csvpy -e [latin1] [data.csv]
copy
Open file without headers
$ csvpy --no-header-row [data.csv]
copy

SYNOPSIS

csvpy [options] file

DESCRIPTION

csvpy is part of csvkit that loads a CSV file into an interactive Python shell for exploration and analysis. The data is available as a reader object or, with --agate, as a full-featured agate Table.
In default mode, the CSV data is loaded into a variable named reader, a csv.reader object. With --dict, it becomes a DictReader where each row is a dictionary. With --agate, it becomes a table variable with analysis capabilities.
This tool is useful for quick data exploration, testing data transformations, and prototyping analysis code. The interactive environment allows immediate feedback while working with the data.

PARAMETERS

FILE

CSV file to load into the Python environment.
-d CHAR, --delimiter CHAR
Field delimiter (default: comma).
-t, --tabs
Use tabs as delimiter.
-e ENCODING, --encoding ENCODING
Input file encoding.
--no-header-row
File has no header row.
--agate
Load file as an agate Table instead of csv reader.
-H, --no-inference
Disable type inference.
--dict
Load as DictReader (rows as dictionaries).

CAVEATS

Large files may use significant memory when loaded entirely. The default reader is consumed after iteration; use --agate for reusable data. Requires familiarity with Python for effective use.

HISTORY

csvpy is part of csvkit, created by Christopher Groskopf in 2011. It provides a quick way to drop into Python for ad-hoc data analysis without writing boilerplate file loading code.

SEE ALSO

csvkit(1), python(1), ipython(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community