https://github.com/berquerant/csvcut
Cut out selected portions of each line of csv from stdin
https://github.com/berquerant/csvcut
rust
Last synced: about 1 year ago
JSON representation
Cut out selected portions of each line of csv from stdin
- Host: GitHub
- URL: https://github.com/berquerant/csvcut
- Owner: berquerant
- Created: 2022-04-27T16:15:42.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-04-21T08:18:26.000Z (about 1 year ago)
- Last Synced: 2025-04-21T09:27:20.051Z (about 1 year ago)
- Topics: rust
- Language: Rust
- Homepage:
- Size: 184 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# csvcut
```
❯ csvcut --help
csvcut
Cut out selected portions of each line of csv from stdin
USAGE:
csvcut [OPTIONS] --target
OPTIONS:
-d, --delimiter
Use DELIMITER as the field delimiter character instead of the ','
[default: ,]
-f, --target
Selected portions.
Single:
```
❯ (echo 'a,b,c';echo '2,3,4';echo '11,12,13') | csvcut -f 1
a
2
11
```
Left limit:
```
❯ (echo 'a,b,c';echo '2,3,4';echo '11,12,13') | csvcut -f 2-
b,c
3,4
12,13
```
Right limit:
```
❯ (echo 'a,b,c';echo '2,3,4';echo '11,12,13') | csvcut -f -2
a,b
2,3
11,12
```
Interval:
```
❯ (echo 'a,b,c,d';echo '1,2,3,4';echo '11,12,13,14') | csvcut -f 2-3
b,c
2,3
12,13
```
Single + Right:
```
❯ (echo 'a,b,c,d';echo '1,2,3,4';echo '11,12,13,14') | csvcut -f 1,3-
a,c,d
1,3,4
11,13,14
```
Single + Right, ignore headers:
```
❯ (echo 'a,b,c,d';echo '1,2,3,4';echo '11,12,13,14') | csvcut -f 1,3- --header
1,3,4
11,13,14
```
-h, --help
Print help information
--header
Read or ignore headers. See --json and --target
-j, --json
Print results as json.
e.g.
```
❯ (echo 'a,b,c';echo '2,3,4';echo '11,12,13') | csvcut -f 2 --json
["b"]
["3"]
["12"]
❯ (echo 'a,b,c';echo '2,3,4';echo '11,12,13') | csvcut -f 2 --json --header
{"b":"3"}
{"b":"12"}
❯ (echo '"a,b","c","d,e,f"';echo '"1","2,3","4"';echo '"11","12","13,14,15"') | csvcut
-f 1,3 --json
["a,b","d,e,f"]
["1","4"]
["11","13,14,15"]
```
```