简体   繁体   English

阅读单行泡菜python

[英]Read single line pickle python

im doing some simulations with python and save the results using pickle.dump(). 我用python做一些模拟,并使用pickle.dump()保存结果。 Now i have an enormous amount of data wich i need to read. 现在我需要读取大量数据。 The data consist of matrices (a lot of lines of numbers) each saved in a single file. 数据由矩阵(多行数字)组成,每个矩阵都保存在一个文件中。 I need to be able to read the information efficiently. 我需要能够有效地阅读信息。

  • How can i read a single line of the matrix withot uploading the complete file? 上载完整文件后,如何读取矩阵的一行?
  • How can i read a specific set of lines (say from the line 1000 to the 2000) whithout uploading the complete file? 在不上传完整文件的情况下,如何读取一组特定的行(例如从1000行到2000行)? Here is the code i used to save the data: 这是我用来保存数据的代码:

     for j in range(61): for l in range(31): X = zeros([100000,100]) K = k[j] A = a[l] X = RK4(deriv,dt,pasos,xo,n,w,b,K,g,A,V) pickle.dump( X, open( 'Vrc'+'dk_'+ str(K) + 'alpha_' + str(A) , "wb" ) ) 

Try using generators when doing pickle.load(): yield pickle.load(...) 在执行pickle.load()时尝试使用生成器: yield pickle.load(...)

Also have a look at cPickle . 也可以看看cPickle

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

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