代码之家  ›  专栏  ›  技术社区  ›  Igor Konoplyanko

Wolfram Mathematica中处理大型数据文件的方法

  •  14
  • Igor Konoplyanko  · 技术社区  · 16 年前

    我想知道在Mathematica中是否存在处理大型文件的方法? 目前我有一个大约500MB的带有表数据的文件。

    Import["data.txt","Table"];
    

    什么是替代方法?

    3 回复  |  直到 13 年前
        1
  •  13
  •   Timo    16 年前

    使用 OpenRead["file"] 这给了你一个 InputStream 可在其上使用的对象 Read[stream] . 根据数据文件的格式,您可能需要在中设置自定义选项值 Read[] 对于 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,"
    
        2
  •  4
  •   gdelfino    16 年前

    您还可以将数据加载到数据库(例如mysql)中,然后使用Mathematica访问它。 DatabaseLink

        3
  •  1
  •   Andrew Barber Eric Lafortune    13 年前

    功能 DumpSave 也有助于保存大型数据集。它以Mathematica的内部格式保存数据,因此在时间和文件大小上都更有效。