파일에서 선택한 열을 잘라내는 방법.
예:
load.sh students.csv | select.sh ‘name’ ‘school_name’
그러면 로드된 파일의 name 및 school_name 열이 터미널에 출력됩니다.
답변1
사용 하거나 csvcut
에서csvsql
csvkit:
csvcut -c name,school_name students.csv
csvsql --query 'select name, school_name from students' students.csv
예:
$ cat students.csv
id,name,surname,school_name,favorite_color
1,Tom,Sawyer,Harvard,red
2,Bob,"the Builder",Oxford,orange
3,John,Sinclair,"Columbine High",blue
4,Walter,Mitty,"Thomas Jefferson High",green
5,Donald,Trump,Unknown,blue
$ csvcut -c name,school_name students.csv
name,school_name
Tom,Harvard
Bob,Oxford
John,Columbine High
Walter,Thomas Jefferson High
Donald,Unknown