Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ahuigo/xcut
Enhanced cut command
https://github.com/ahuigo/xcut
Last synced: 3 months ago
JSON representation
Enhanced cut command
- Host: GitHub
- URL: https://github.com/ahuigo/xcut
- Owner: ahuigo
- Created: 2018-07-23T16:14:56.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-29T14:35:56.000Z (over 4 years ago)
- Last Synced: 2024-07-24T14:36:12.271Z (3 months ago)
- Language: Python
- Size: 13.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-hacking-lists - ahuigo/xcut - Enhanced cut command (Python)
README
# Xcut
Xcut is an Enhanced cut command, which is used to help grep column.[![](https://img.shields.io/pypi/pyversions/xcut.svg?longCache=True)](https://pypi.org/pypi/xcut/)
[![](https://img.shields.io/pypi/v/xcut.svg?maxAge=36000)](https://pypi.org/pypi/xcut/)
[![Build Status](https://travis-ci.org/ahuigo/xcut.svg?branch=master)](https://travis-ci.org/ahuigo/xcut)## Install
pip install xcut
pip3 install xcutxcut --help
## Usage
Let's test a file named `test.csv`> ~ cat test/test.csv
name,gender,job
Jack,male,coder
Lucy,female,artistCut fields
> ~ xcut -f job,name test/test.csv
job,name
coder,Jack
artist,Lucy### Set title type
The default title type is head: `-t head`> ~ xcut -f name,gender test/test.csv
Set title type to index: `-t index`
> ~ xcut -f 1,3 -t index test/test.csv
1,3
name,job
Jack,coder
Lucy,artistSet title type to custom(`--titles TITLES`)
> ~ xcut -f '职业,姓名' --titles '姓名,性别,职业' test/test.csv -od $'\t'
职业 姓名
job name
coder Jack
artist LucySet title type to kv(`-t kv`)
> ~ echo 'key1=v1,key2=v2,key3=v3' | xcut -f key3,key2 -t kv
key3,key2
v3,v2### Set input delimiter(d)
> ~ xcut -f job,name test/test.csv -d ',' -od '`'
job`name
coder`Jack
artist`Lucy### Set output delimiter(od)
> ~ xcut -f job,name test/test.csv -od '`'
job`name
coder`Jack
artist`Lucy### pretty output
You could set the output delimiter(od), also you can print it via `pretty`> ~ xcut -f '职业,姓名' --titles '姓名,性别,职业' test/test.csv -od $'\t\t' --pretty
职业 姓名
----------------------------------------
job name
coder Jack
artist Lucy### Use csv format
Not only you could parse csv format file with `--from-csv`:$ echo 'Lucy,"98,99",23' | python xcut -f scores,name --titles name,scores,age
scores,name
"98,Lucy$ echo 'Lucy,"98,99",23' | python xcut -f scores,name --titles name,scores,age --from-csv
scores,name
98,99,LucyYou could also save the output to csv format with(`--to-csv`)
$ echo 'Lucy,"98,99",23' | python xcut -f scores,name --titles name,scores,age --from-csv --to-csv
scores,name
"98,99",Lucy## Required
1. python>=3.5
2. click