如何从一个CSV文件中的每一行的第一列? [英] How to get the first column of every line from a CSV file?
本文介绍了如何从一个CSV文件中的每一行的第一列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获得在输入CSV文件和输出每行的第一列到一个新的文件吗?我使用 AWK
但不知道如何。
How do get the first column of every line in an input CSV file and output to a new file? I am thinking using awk
but not sure how.
推荐答案
试试这个:
awk -F"," '{print $1}' data.txt
这将文件中的每个输入行分割的data.txt
进入基于不同的领域,
字符(如与 -F
)指定,第一个字段(列)打印到标准输出。
It will split each input line in the file data.txt
into different fields based on ,
character (as specified with the -F
) and print the first field (column) to stdout.
这篇关于如何从一个CSV文件中的每一行的第一列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文