mirror of https://github.com/CrimsonTome/tldr.git
commit
254cc5977c
|
@ -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}}`
|
|
@ -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}}`
|
|
@ -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}}`
|
|
@ -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}}`
|
|
@ -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}}`
|
|
@ -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}}`
|
|
@ -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}}`
|
|
@ -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}}`
|
|
@ -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}}`
|
Loading…
Reference in New Issue