Wolfram Mathematica 中处理大数据文件的方法 [英] Way to deal with large data files in Wolfram Mathematica
本文介绍了Wolfram Mathematica 中处理大数据文件的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否有办法在 Mathematica 中处理大文件?目前我有一个大约 500Mb 的文件,其中包含表数据.
I wonder if there exists way to work with large files in Mathematica ? Currently I have a file about 500Mb with table data.
Import["data.txt","Table"];
什么是替代方式?
推荐答案
使用 OpenRead["file"]
它为您提供了一个 InputStream
对象,您可以在该对象上使用 Read[stream]
.根据数据文件的格式,您可能需要在 Read 中设置自定义选项值[]
用于 RecordSeparators
.
Use OpenRead["file"]
which gives you an InputStream
object on which you can use Read[stream]
. Depending on the formatting of the data file you may need to set custom option values in Read[]
for RecordSeparators
.
示例:
In[1]:= str = OpenRead["ExampleData/USConstitution.txt"]
Out[1]= InputStream["ExampleData/USConstitution.txt", 24]
In[2]:= Read[str, Word]
Out[2]= "We"
In[3]:= Read[str, Word]
Out[3]= "the"
In[4]:= Read[str, Record]
Out[4]= "People of the United States, in Order to form a more perfect Union,"
这篇关于Wolfram Mathematica 中处理大数据文件的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文