English 中文(简体)
unix 重新定向 csv 文件中的 Csv 文件
原标题:Unix redirecting csv file

刚从Unix开始 需要研究这个:

I have a csv file with 3 columns. Using Terminal in Unix I need to cut the columns and get each column to create a text file of the info in the column.

第1第1第2第3第3分

1.txt col2.txt col3.txt cool3.txt cool2.txt cool3.txt cool3.txt cool.txt cool.txt

最佳回答

此“ oneliner” 脚本应该帮助 : () 只要将您的 CSV 数据插入 q. csv 文件, 或者更改脚本中的文件名 。

 for i in `cat q.csv`; do  echo $i|awk  -F,   { print $1 }   >> 1.txt  ; echo $i|awk  -F,   { print $2 }   >> 2.txt; echo $i|awk  -F,   { print $3 }   >> 3.txt; done
问题回答

您是否熟悉 "http://en.wikipedia.org/wiki/Awk" rel="nofollow">awk ?

假设您有一个 csv 文件, 以逗号分隔列的 csv 文件, 以下只输出第二列 :

awk -F ","  {print $2}  yourFilename.txt




相关问题
Styling rows in table that uses CSV data through PHP

I ve been working on this simple code that puts a CSV file into a nice table. But because the data is imported, styling ODD rows is a pretty hard thing to do. All I need would be a method to address ...

PHP - Sanitise a comma separated string

What would be the most efficient way to clean a user input that is a comma separated string made entirely on numbers - e.g 2,40,23,11,55 I use this function on a lot of my inputs function clean($...

marking duplicates in a csv file

I m stumped with a problem illustrated in the sample below: "ID","NAME","PHONE","REF","DISCARD" 1,"JOHN",12345,, 2,"PETER",6232,, 3,"JON",12345,, 4,"PETERSON",6232,, 5,"ALEX",7854,, 6,"JON",12345,, ...

Interactive heat map in Flex

I’m at a very basic level with Flex and with programming in general. I am working on a project where I have data in an Excel (.csv) format, it’s a large Excel plot/matrix where each cell has a ...

热门标签