AWK:无法打开"04477C9A875B80.csv"用于输出(打开的文件太多) [英] AWK: cannot open "04477C9A875B80.csv" for output (Too many open files)

查看:52
本文介绍了AWK:无法打开"04477C9A875B80.csv"用于输出(打开的文件太多)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很大的CSV文件,需要将其拆分为多个CSV文件,使用第3列作为标识符,结果文件将由第3列中的值命名

I have a large CSV file and need to split it too multiple CSV files, using column 3 as the identifier and the resultant files will be named by the value in column 3

我正在使用以下内容:

awk -F ',' '{print > ($3".csv")}' playpass.csv

但是我遇到了错误:

awk: cannot open "04477C9A875B80.csv" for output (Too many open files)

我知道我需要关闭文件,但经过几次尝试,我无处可去,现在又回到了空白画布上

I know I need to close the files but after a few attempts, I'm getting nowhere and now back to a blank canvas

由于遇到相同的错误,我没有运气尝试了以下内容

I tried the following with no luck as I get the same error

awk -F ',' '{close($1); i++}{print > $1}' query_result_2019-07-20T15_31_42.941Z.csv

有什么建议吗?

推荐答案

您正试图在关闭之前关闭输出文件以写入文件,而不是在打开文件之后将其关闭.更改此:

You're trying to close the output file before you open it to write to it instead of after you've opened it. Change this:

'{close($1); i++}{print > $1}'

对此:

'{print > $1}{close($1); i++}'

您的脚本中当然还有其他问题,但是没有示例输入/输出,我不想提出任何建议.

There are other issues with your script of course but without sample input/output I don't want to make any suggestions.

这篇关于AWK:无法打开"04477C9A875B80.csv"用于输出(打开的文件太多)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆