lundi 6 avril 2015

how enter a big file with 10 million row in python?


Vote count:

0




I want to enter a file with 10 million users and passwords in python for analyzing. File is in text format. here some lines of data:



0000 00000000
0000 00001
0000 00001111
0000 000099
0000 00009999
0000 0000w
0000 5927499
0000 634252
0000 6911703
0000 701068


in python I used following code to read the file:



f=open('10-million-combos.txt','r')
a=[]
for line in f.readlines():
a.append(line)


the following code takes a few seconds. data saved in a list as following format:



>>>a[0:2]
['0000\t00000000\n', '0000\t00001\n']


for extracting users and passwords I used:



b=[]
for i in a:
b.append(i.split('\t'))


The problem is, above code encounter memory error after a long time and I can't separate users and passwords. Do you have any suggestions for this matter?



asked 26 secs ago







how enter a big file with 10 million row in python?

Aucun commentaire:

Enregistrer un commentaire