MS Excel可以显示 1,048,576 行。虽然这在正常使用中可能看起来非常大,但在很多情况下这还不够。
无论您是查看日志文件还是大型数据集,很容易遇到包含数百万行的CSV文件或巨大的文本文件。由于Excel无法支持这么大的文件,您究竟如何打开它们?让我们来了解一下。
为什么普通文本编辑器(Normal Text Editors)无法打开非常大的文件(Open Really Large Files)?
计算机有千兆字节的存储空间,为什么文本编辑器不能打开大文件?
这里有两个因素在起作用。某些应用程序对它们可以显示的数据量有硬编码限制。不管你的电脑有多少内存,他们只是不会使用它。
第二个问题是RAM。许多文本编辑器对行数没有硬性限制,但由于内存限制,无法显示大文件。他们将整个文件加载到系统RAM中,因此如果此内存不够大,则该过程将失败。
方法#1:使用免费编辑器
查看超大文本文件的最佳方法是使用……文本编辑器。不仅仅是任何文本编辑器,而是用于编写代码的工具。此类应用程序通常可以毫无障碍地处理大文件并且是免费的。
大文本文件查看器(Large Text File Viewer)可能是这些应用程序中最简单的。它非常易于使用,运行速度快,并且资源占用非常低。唯一的缺点?它无法编辑文件。但如果您只想查看大型CSV文件,这无疑是完成这项工作的最佳工具。
对于编辑大型文本文件,您应该尝试Emacs。最初是为Unix系统创建的,它在Windows上也能很好地工作,并且可以处理大文件。同样,Neovim和Sublime Text是两个轻量级IDE(IDEs),可用于打开千兆字节大小的CSV文本文件。
如果您正在寻找的只是通过大型日志文件搜索数据,那么klogg就是适合您的工具。流行的glogg(glogg)的更新分支,此应用程序允许您轻松地通过巨大的文本文件执行复杂的搜索操作。由于计算机生成的日志文件通常可以包含数百万行,因此 klogg 旨在处理此类文件大小而不会出现问题。
方法(Method)#2:拆分成多个部分(Into Multiple Parts)
尝试打开大型CSV文件的整个问题是它们太大了。但是,如果您要将它们分成多个较小的文件怎么办?
这是一种流行的解决方案,因为它通常不需要学习新文本编辑器的界面。相反,您可以使用在线提供的众多 CSV 拆分器之一,(one of the many CSV splitters available online)将大文件拆分为多个易于打开的文件。然后可以正常访问这些文件中的每一个。
但是,这不是解决此问题的最佳方法。拆分大文件通常会导致奇怪的拼写错误或配置不正确的文件。此外,单独打开每个块可以防止您一次过滤整个数据。
方法#3:导入数据库
扩展到数 GB 的文本和 .csv 文件通常是大型数据集。那么为什么不直接将它们导入数据库呢?
SQL是当今最常用的数据库标记语言。使用的 SQL 版本(many versions of SQL)有很多,但最简单的可能是MySQL。幸运的是,可以将 CSV 文件转换为 MySQL 表(convert a CSV file into a MySQL table)。
这绝不是处理大型CSV文件的最简单方法,因此我们仅在您想定期处理大型数据集时才推荐此方法。如果MySQL听起来太难,您可以随时将 .csv 文件导入MS Access。
方法(Method)#4:使用Python库进行分析
当您使用包含数百万行数据的 .csv 文件时,您显然无法手动理解它。您可能希望过滤数据并运行特定查询以了解趋势。
那么为什么不编写 Python 代码(write Python code)来做到这一点呢?
再一次,这不是最用户友好的方法。虽然Python 不是最难学习的编程语言(Python isn’t the hardest programming language to learn),但它是编码,因此它可能不是最适合您的方法。尽管如此,如果您发现自己每天都必须解析非常大的CSV文件,您可能希望(CSV)使用一些 Python 代码自动执行该任务(automate the task with some Python code)。
方法#5:使用高级工具
我们在第一种方法中看到的文本编辑器并不是用于CSV处理的专用工具。它们是通用工具,也可用于处理大型 .csv 文件。
但是专门的应用程序呢?是否没有为解决此问题而创建的应用程序?
有,其实。例如,CSV Explorer建立在我们在最后两种方法( (CSV Explorer)SQL数据库和Python代码)中描述的过程之上,以创建能够查看和编辑任何大小的CSV文件的应用程序。(CSV)您可以使用电子表格工具完成您期望的所有操作,例如在CSV Explorer中创建图表或过滤数据。
另一种选择是UltraEdit。与之前的工具不同,这不仅适用于 .csv 文件,还适用于任何类型的文本文件。它可以轻松处理大小不等的文本和CSV文件,其界面类似于我们之前讨论的许多免费编辑器。
这些工具的唯一缺点是它们是高级应用程序,需要您获得付费许可证才能使用它们。您可以随时试用他们的免费试用版来查看他们的功能,或者如果您只有一次性使用。
打开大文本(Large Text)和CSV 文件(CSV Files)的最佳方式是什么?
在这个大数据时代,遇到高达千兆字节的文本文件并不少见,甚至使用(Big Data)记事本(Notepad)或MS Excel等内置工具都难以查看。为了能够打开如此大的CSV文件,您需要下载并使用第三方应用程序。
如果您只想查看此类文件,那么大文本文件查看器(Large Text File Viewer)是您的最佳选择。要实际编辑它们,您可以尝试使用功能丰富的文本编辑器,例如Emacs,或者使用高级工具,例如CSV Explorer。
拆分CSV文件或将其导入数据库等技术涉及的步骤太多。如果您发现自己经常处理大量文本文件,最好获得专用高级工具的付费许可证。
How to Open Really Large Text and CSV Files
MS Excel can display 1,048,576 rows. While thаt may seem likе a really large number in normal usage, there are plеnty of scenarios where that isn’t quite enough.
Whether you’re looking at log files or large data sets, it’s easy to come across CSV files with millions of rows or enormous text files. Since Excel cannot support files this large, how exactly do you open them? Let’s find out.
Why Can Normal Text Editors Not Open Really Large Files?
A computer has gigabytes of storage, so why can’t text editors open large files?
There are two factors at play here. Some applications have a hardcoded limit on how much data they can display. It doesn’t matter how much memory your PC has, they just won’t use it.
The second issue is RAM. Many text editors do not have a hard limit on the number of rows, but cannot display large files due to memory limitations. They load the entire file into the system RAM, so if this memory isn’t large enough, the process fails.
Method #1: Using Free Editors
The best way to view extremely large text files is to use… a text editor. Not just any text editor, but the tools meant for writing code. Such apps can usually handle large files without a hitch and are free.
Large Text File Viewer is probably the simplest of these applications. It’s really easy to use, works fast and has a very low resource footprint. The only downside? It cannot edit the files. But if you only want to view large CSV files, this is hands down the best tool for the job.
For editing large text files as well, you should try Emacs. Originally created for Unix systems, it works perfectly well on Windows as well, and can handle large files. Similarly, Neovim and Sublime Text are two lightweight IDEs that can be used to open gigabyte-sized CSV text files.
If all you’re looking for is to search for data through large log files, then klogg is just the tool for you. An updating fork of the popular glogg, this application allows you to perform complex search operations through enormous text files with ease. Since computer-generated log files can often have millions of rows, klogg is designed to work with such file sizes without an issue.
Method #2: Split Into Multiple Parts
The whole problem with trying to open large CSV files is that they are too large. But what if you were to split these into multiple smaller files?
This is a popular solution, as it generally doesn’t involve having to learn the interface of a new text editor. Instead, you can use one of the many CSV splitters available online to break up the large file into a number of easy-to-open files. Each of these files can then be accessed normally.
However, this isn’t the best way to go about this. Splitting a large file can often lead to weird typos or improperly configured files. Moreover, opening each chunk separately prevents you from filtering through the whole data at once.
Method #3: Import Into a Database
Text and .csv files extending to multiple gigabytes are generally large datasets. So why not just import them into a database?
SQL is the most common database markup language used these days. There are many versions of SQL in use, but the easiest is probably MySQL. And as luck would have it, it is possible to convert a CSV file into a MySQL table.
This is by no means the easiest method of dealing with large CSV files, so we only recommend this if you want to deal with large datasets on a regular basis. If MySQL sounds too tough, you can always import your .csv files to MS Access instead.
Method #4: Analyze With Python Libraries
When you’re working with a .csv file with millions of rows of data, you’re obviously not going to be able to make much sense of it manually. You probably want to filter the data and run specific queries to understand trends.
So why not write Python code to do just that?
Once again, this is not the most user-friendly method. While Python isn’t the hardest programming language to learn, it is coding, so it might not be the best approach for you. Still, if you find yourself having to parse through really large CSV files on a daily basis, you might want to automate the task with some Python code.
Method #5: With Premium Tools
The text editors we saw in the first method weren’t dedicated tools meant for CSV processing. They were general-purpose tools that could be used to work with large .csv files as well.
But what about specialized applications? Are there no apps out there that are created to solve this problem?
There are, actually. CSV Explorer, for example, builds on the very process we described in the last two methods (SQL database and Python code) to create an app capable of viewing and editing CSV files of any size. You can do everything you expect from a spreadsheet tool like create graphs or filter the data in CSV Explorer.
Another option is UltraEdit. Unlike the previous tool, this is meant not just for .csv files but for any type of text file. It can easily handle text and CSV files ranging to a few gigabytes, with an interface similar to many of the free editors we discussed earlier.
The only drawback with these tools is that they are premium applications, requiring you to get a paid license to be able to use them. You can always try out their free trial versions to check out their features, or if you only have a one-time use.
What Is the Best Way To Open Large Text and CSV Files?
In this age of Big Data, it’s not uncommon to run into text files running into gigabytes, which can be hard to even view with built-in tools like Notepad or MS Excel. To be able to open such large CSV files, you need to download and use a third-party application.
If all you want is to view such files, then Large Text File Viewer is the best choice for you. For actually editing them, you can try a feature-rich text editor like Emacs, or go for a premium tool like CSV Explorer.
Techniques like splitting the CSV file or importing it into a database involve just too many steps. You’re better off getting a paid license of a dedicated premium tool if you find yourself working with huge text files a lot.