如何对非常大的CSV文件进行排序? [英] How can I sort a very large CSV file?

查看:82
本文介绍了如何对非常大的CSV文件进行排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有294,000行大型csv,第1列中的网址,第2列中的数字.

I have this large 294,000 row csv with urls in column 1 and numbers in column 2.

我需要按照从最小到最大的顺序对它们进行排序.我已将其加载到软件"CSVed"中,并且可以正常处理,它不会崩溃或发生任何事情,但是当我单击列顶部以对其进行排序时,它并没有按照从小到大的顺序排列都糊涂了.

I need to sort them from the smallest number to the largest number. I have loaded it into the software 'CSVed' and it handles it okay, it doesn't crash or anything but when I click the top of the column to sort it, it doesn't make it in order from smallest to largest, it's all just muddled up.

有人有什么想法吗?我整天都在搜寻,我想我可能会在这里问.

Anyone have any ideas? I've been searching around all day, I thought I might ask here.

谢谢.

推荐答案

您可以使用gnu排序.它占用的内存很小,甚至可以使用多个CPU进行排序.

You can use gnu sort. It takes has small memory footprint and can even use multiple CPUs for sort.

sort -t ,  -k 2n file.csv

Gnu sort在大多数Linux发行版以及MacOS中都默认可用(尽管稍后会有稍微不同的选项).您也可以在Windows上安装它,例如,从 Windows版CoreUtils 页中.

Gnu sort is available by default in most of linux distributions as well as for MacOS by default (though later has slightly different options). You can install it for windows as well, for example from CoreUtils for Windows page.

有关排序调用的更多信息,请使用手册

For more information about sort invocation use the manual

这篇关于如何对非常大的CSV文件进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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