CSVPY(1)

✨ NAME ✨

csvpy β€” csvpy Documentation

bestie she's a lil legend from the csvkit manual (that's the manual name, we're literally in it πŸ’…) and she's here to hand you a loaded-up CSV object and a whole Python shell to play in πŸπŸ’–


🐍 DESCRIPTION 🐍

okay so here's the vibe: csvpy loads a CSV file into an agate.csv.Reader object and then drops you straight into a Python shell so you can inspect the data however you see fit. main character energy fr fr.

Here's the literal help text, no edits, no cap:

          usage: csvpy [-h] [-d DELIMITER] [-t] [-q QUOTECHAR] [-u {0,1,2,3}] [-b]
                       [-p ESCAPECHAR] [-z FIELD_SIZE_LIMIT] [-e ENCODING] [-L LOCALE]
                       [-S] [--blanks] [--null-value NULL_VALUES [NULL_VALUES ...]]
                       [--date-format DATE_FORMAT] [--datetime-format DATETIME_FORMAT]
                       [-H] [-K SKIP_LINES] [-v] [-l] [--zero] [-V] [--dict] [--agate]
                       [--no-number-ellipsis] [-y SNIFF_LIMIT] [-I]
                       [FILE]

          Load a CSV file into a CSV reader and then drop into a Python shell.

          positional arguments:
            FILE                  The CSV file to operate on. If omitted, will accept
                                  input as piped data via STDIN.

          optional arguments:
            -h, --help            show this help message and exit
            --dict                Load the CSV file into a DictReader.
            --agate               Load the CSV file into an agate table.
            --no-number-ellipsis  Disable the ellipsis if the max precision is exceeded.
            -y SNIFF_LIMIT, --snifflimit SNIFF_LIMIT
                                  Limit CSV dialect sniffing to the specified number of
                                  bytes. Specify "0" to disable sniffing entirely, or
                                  "-1" to sniff the entire file.
            -I, --no-inference    Disable type inference (and --locale, --date-format,
                                  --datetime-format, --no-leading-zeroes) when parsing
                                  the input.

and now let me translate that for you, cutie by cutie πŸŽ€

🌸 the positional argument 🌸

  • FILE β€” the CSV file you wanna operate on. if you omit it, she'll accept input as piped data via STDIN.

πŸ’… the optional arguments πŸ’…

  • -h, --help β€” shows this help message and dips. iconic behaviour.
  • --dict β€” loads the CSV file into a DictReader.
  • --agate β€” loads the CSV file into an agate table.
  • --no-number-ellipsis β€” disables the ellipsis if the max precision is exceeded.
  • -y SNIFF_LIMIT, --snifflimit SNIFF_LIMIT β€” limits CSV dialect sniffing to the specified number of bytes. specify "0" to disable sniffing entirely, or "-1" to sniff the entire file. so many options, so much power ✨
  • -I, --no-inference β€” disables type inference (and --locale, --date-format, --datetime-format, --no-leading-zeroes) when parsing the input.

this tool will automatically use the IPython shell if it is installed, otherwise it will use the running Python shell. she's adaptable like that πŸ¦‹

NOTE: due to platform limitations, csvpy does not accept file input as piped data via STDIN. 😭 i know. tragic. but that's just how it is.

See also: Arguments common to all tools. πŸ‘€


πŸ“ EXAMPLES πŸ“

basic use πŸŽ€

$ csvpy examples/dummy.csv
       Welcome! "examples/dummy.csv" has been loaded in a reader object
       named "reader".  >>> next(reader) ['a', 'b', 'c']

as a dictionary πŸ“–

$ csvpy --dict examples/dummy.csv
Welcome! "examples/dummy.csv" has been loaded in a DictReader object named "reader".
>>> next(reader)
{'a': '1', 'c': '3', 'b': '2'}

as an agate table 🌈

$ csvpy --agate examples/dummy.csv
Welcome! "examples/dummy.csv" has been loaded in a from_csv object named "reader".
>>> reader.print_table()
|    a | b | c |
| ---- | - | - |
| True | 2 | 3 |

πŸ‘‘ AUTHOR πŸ‘‘

Christopher Groskopf and contributors β€” shoutout to the whole squad 🫢


2016, Christopher Groskopf and James McKinney


and that's the whole page, bestie ✨ this was version 2.2.0, dated Aug 16, 2024, straight out of csvkit. go forth and next(reader) your way into the sunset πŸŒ…πŸ’–πŸŽ€

πŸ“¦ where this page comes from