CSVPY(1) csvkit CSVPY(1)

csvpy - بارگذاری یک فایل CSV در پوسته تعاملی پایتون

یک فایل CSV را درون شیء agate.csv.Reader بارگذاری کرده و سپس وارد پوستهٔ پایتون می‌شود تا کاربر بتواند داده‌ها را به هر شکلی که مناسب می‌داند بررسی کند:

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.

این ابزار در صورت نصب بودن IPython به طور خودکار از آن استفاده خواهد کرد، در غیر این صورت از پوستهٔ پیش‌فرض پایتون استفاده می‌کند.

نکته:

به دلیل محدودیت‌های سیستم‌عامل، csvpy ورودی فایل را به صورت داده‌های لوله‌کشی‌شده (piped) از طریق STDIN نمی‌پذیرد.

همچنین ببینید: آرگومان‌های مشترک میان تمام ابزارها.

استفاده پایه:

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

به عنوان یک دیکشنری:

$ 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'}

به عنوان یک جدول agate:

$ 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 |

Christopher Groskopf و مشارکت‌کنندگان

2016, Christopher Groskopf and James McKinney

August 16, 2024 2.2.0