diff --git a/pages/common/csvclean.md b/pages/common/csvclean.md new file mode 100644 index 000000000..612748e3b --- /dev/null +++ b/pages/common/csvclean.md @@ -0,0 +1,12 @@ +# csvclean + +> Finds and cleans common syntax errors in CSV files. +> Included in csvkit. + +- Clean a CSV file: + +`csvclean {{bad.csv}}` + +- List locations of syntax errors in a CSV file: + +`csvclean -n {{bad.csv}}` diff --git a/pages/common/csvcut.md b/pages/common/csvcut.md new file mode 100644 index 000000000..03ad76f09 --- /dev/null +++ b/pages/common/csvcut.md @@ -0,0 +1,20 @@ +# csvcut + +> Filter and truncate CSV files. Like Unix's `cut` command, but for tabular data. +> Included in csvkit. + +- Print indices and names of all columns: + +`csvcut -n {{data.csv}}` + +- Extract the first and third columns: + +`csvcut -c {{1,3}} {{data.csv}}` + +- Extract all columns **except** the fourth one: + +`csvcut -C {{4}} {{data.csv}}` + +- Extract the columns named "id" and "first name" (in that order): + +`csvcut -c {{id,"first name"}} {{data.csv}}` diff --git a/pages/common/csvformat.md b/pages/common/csvformat.md new file mode 100644 index 000000000..16276fbb1 --- /dev/null +++ b/pages/common/csvformat.md @@ -0,0 +1,24 @@ +# csvformat + +> Convert a CSV file to a custom output format. +> Included in csvkit. + +- Convert to a tab-delimited file (TSV): + +`csvformat -T {{data.csv}}` + +- Convert delimiters to a custom character: + +`csvformat -D "{{custom_character}}" {{data.csv}}` + +- Convert line endings to carriage return (^M) + line feed: + +`csvformat -M "{{\r\n}}" {{data.csv}}` + +- Minimize use of quote characters: + +`csvformat -U 0 {{data.csv}}` + +- Maximize use of quote characters: + +`csvformat -U 1 {{data.csv}}` diff --git a/pages/common/csvgrep.md b/pages/common/csvgrep.md new file mode 100644 index 000000000..bc7458ebc --- /dev/null +++ b/pages/common/csvgrep.md @@ -0,0 +1,16 @@ +# csvgrep + +> Filter CSV rows with string and pattern matching. +> Included in csvkit. + +- Find rows that have a certain string in column 1: + +`csvgrep -c {{1}} -m {{string_to_match}} {{data.csv}}` + +- Find rows in which columns 3 or 4 match a certain regex pattern: + +`csvgrep -c {{3,4}} -r {{regex_pattern}} {{data.csv}}` + +- Find rows in which the "name" column does NOT include the string "John Doe": + +`csvgrep -i -c {{name}} -m {{"John Doe"}} {{data.csv}}` diff --git a/pages/common/csvlook.md b/pages/common/csvlook.md new file mode 100644 index 000000000..3abdb0e23 --- /dev/null +++ b/pages/common/csvlook.md @@ -0,0 +1,8 @@ +# csvlook + +> Render a CSV file in the console as a fixed-width table. +> Included in csvkit. + +- View a CSV file: + +`csvlook {{data.csv}}` diff --git a/pages/common/csvpy.md b/pages/common/csvpy.md new file mode 100644 index 000000000..c49bd1536 --- /dev/null +++ b/pages/common/csvpy.md @@ -0,0 +1,12 @@ +# csvpy + +> Loads a CSV file into a Python shell. +> Included in csvkit. + +- Load a CSV file into a `CSVKitReader` object: + +`csvpy {{data.csv}}` + +- Load a CSV file into a `CSVKitDictReader` object: + +`csvpy --dict {{data.csv}}` diff --git a/pages/common/csvsort.md b/pages/common/csvsort.md new file mode 100644 index 000000000..c4150ddce --- /dev/null +++ b/pages/common/csvsort.md @@ -0,0 +1,20 @@ +# csvsort + +> Sorts CSV files. +> Included in csvkit. + +- Sort a CSV file by column 9: + +`csvsort -c {{9}} {{data.csv}}` + +- Sort a CSV file by the "name" column in descending order: + +`csvsort -r -c {{name}} {{data.csv}}` + +- Sort a CSV file by column 2, then by column 4: + +`csvsort -c {{2,4}} {{data.csv}}` + +- Sort a CSV file without inferring data types: + +`csvsort --no-inference -c {{columns}} {{data.csv}}` diff --git a/pages/common/csvstat.md b/pages/common/csvstat.md new file mode 100644 index 000000000..36fcbb62c --- /dev/null +++ b/pages/common/csvstat.md @@ -0,0 +1,24 @@ +# csvstat + +> Print descriptive statistics for all columns in a CSV file. +> Included in csvkit. + +- Show all stats for all columns: + +`csvstat {{data.csv}}` + +- Show all stats for columns 2 and 4: + +`csvstat -c {{2,4}} {{data.csv}}` + +- Show sums for all columns: + +`csvstat --sum {{data.csv}}` + +- Show the max value length for column 3: + +`csvstat -c {{3}} --len {{data.csv}}` + +- Show the number of unique values in the "name" column: + +`csvstat -c {{name}} --unique {{data.csv}}` diff --git a/pages/common/in2csv.md b/pages/common/in2csv.md new file mode 100644 index 000000000..6342fe081 --- /dev/null +++ b/pages/common/in2csv.md @@ -0,0 +1,20 @@ +# in2csv + +> Converts various tabular data formats into CSV. +> Included in csvkit. + +- Convert an XLS file to CSV: + +`in2csv {{data.xls}}` + +- Convert a DBF file to a CSV file: + +`in2csv {{data.dbf}} > {{data.csv}}` + +- Convert a specific sheet from an XLSX file to CSV: + +`in2csv --sheet={{sheet_name}} {{data.xlsx}}` + +- Pipe a JSON file to in2csv: + +`cat {{data.json}} | in2csv -f json > {{data.csv}}`