简体   繁体   English

用命令行拆分大型csv文件

[英]splitting large csv file with command line

I know OSX supports the linux-like split command. 我知道OSX支持类似linux的split命令。

I have a huge file file.csv 我有一个巨大的文件file.csv

When I run 我跑的时候

split -l 1000 file.csv new_

I get created one file new_aa but this file is the same as file.csv , it is not split. 我创建了一个文件new_aa但是这个文件和file.csv ,它没有被拆分。

EDIT : when I run file file.csv, I get ASCII text, with CR line terminators . 编辑:当我运行文件file.csv时,我得到ASCII text, with CR line terminators Btw, running wc -l command shows that file.csv has 0 line 顺便说一句,运行wc -l命令显示file.csv0

Your command is just fine: 你的命令很好:

split -l 1000 file.csv new_

However, it seems that you have some encoding problems. 但是,您似乎遇到了一些编码问题。 When you say file file.csv you get 当你说file file.csv你得到

ASCII text, with CR line terminators ASCII文本,带CR行终止符

So what you need is to port this file from MAC to UNIX. 所以你需要的是将这个文件从MAC移植到UNIX。 And this can be done with either of these: 这可以通过以下任何一种方式完成:

mac2unix file.csv
dos2unix -c mac file.csv

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM