![]() |
![]()
| ![]() |
![]()
NAMEin2csv - in2csv Documentation DESCRIPTIONConverts various tabular data formats into CSV. Converting fixed width requires that you provide a schema file with the "-s" option. The schema file should have the following format: column,start,length name,0,30 birthday,30,10 age,40,3 The header line is required though the columns may be in any order: usage: in2csv [-h] [-d DELIMITER] [-t] [-q QUOTECHAR] [-u {0,1,2,3}] [-b] See also: Arguments common to all tools. NOTE: The "ndjson" format refers to "newline
delimited JSON", as used by many streaming APIs.
NOTE: If an XLS looks identical to an XLSX when viewed in
Excel, they may not be identical as CSV. For example, XLSX has an integer
type, but XLS doesn't. Numbers that look like integers from an XLS will have
decimals in CSV, but those from an XLSX won't.
NOTE: To convert from HTML, consider messytables.
EXAMPLESConvert the 2000 census geo headers file from fixed-width to CSV and from latin-1 encoding to utf8: in2csv -e iso-8859-1 -f fixed -s examples/realdata/census_2000/census2000_geo_schema.csv examples/realdata/census_2000/usgeo_excerpt.upl NOTE: A library of fixed-width schemas is maintained in the
ffs project:
https://github.com/wireservice/ffs Convert an Excel .xls file: in2csv examples/test.xls Standardize the formatting of a CSV file (quoting, line endings, etc.): in2csv examples/realdata/FY09_EDU_Recipients_by_State.csv Fetch csvkit's open issues from the GitHub API, convert the JSON response into a CSV and write it to a file: curl https://api.github.com/repos/wireservice/csvkit/issues?state=open | in2csv -f json -v Convert a DBase DBF file to an equivalent CSV: in2csv examples/testdbf.dbf This tool names unnamed headers. To avoid that behavior, run: in2csv --no-header-row examples/test.xlsx | tail -n +2 TROUBLESHOOTINGIf an error like the following occurs when providing an input file in CSV or Excel format: ValueError: Row 0 has 11 values, but Table only has 1 columns. Then the input file might have initial rows before the header and data rows. You can skip such rows with --skip-lines (-K): in2csv --skip-lines 3 examples/test_skip_lines.csv If an XLSX file yields too few rows or too few columns, then the application that created the file might have incorrectly set the worksheet's dimensions. Try again with the --reset-dimensions option. AUTHORChristopher Groskopf and contributors COPYRIGHT2016, Christopher Groskopf and James McKinney
|