gpt4 book ai didi

linux - 删除大型 csv 文件的列

转载 作者:太空宇宙 更新时间:2023-11-04 12:32:16 24 4
gpt4 key购买 nike

我有一个大约 2 GB 的大型 CSV 文件,其中包含 7 列。我想删除它的第 4 列,这是一个文本(片段)。我使用了如下“剪切”命令:

cut -d, f 4 -- complement file

但它不会删除该列,因为每当在一行中遇到逗号时它都会创建列并从该行中删除第 4 列。以下回答here ,我用过csvquote喜欢:

csvquote file | cut -d "," -f 4 --complement | uniq -c | csvquote -u

它适用于小文件,但对于大文件会抛出错误:

errno: Value too large for defined data type

我想知道删除大数据文件列的一些解决方案。谢谢。

编辑:头文件输出:

funny,user_id,review_id,text,business_id,stars,date,useful,type,cool 0,WV5XKbgVHJXEgw7f-b6PVA,hhmpSM4LcHQv6noXlYYCgw,"Went out of our way to find this place because I read they had amazing poutine. Worth the traveling. It really was spot on amazing. Served out of a storage container this place is hip. $10 for two huge portions of poutine. The fries were crisp and held up to the creamy gravy well. Topped with a huge portion of squeaky white cheese curds this was a fantastic meal.

最佳答案

您是否尝试过告诉 cut 使用其他字段?

像这样:

trucks | cut -f 1,3- -d , | uniq -c | csvquote/csvquote -u

我在我的机器上测试过它,它似乎可以工作。但是我没有看到你的数据样本,你也没有注意到哪个程序在抛出

errno: Value too large for defined data type

关于linux - 删除大型 csv 文件的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43000907/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com