Old man, what I read in the size of a 1 g in python CSV, content is a two-dimensional matrix, element of 10 decimal places, how to convert it to a list of the list? I now have pandas readcsv read and then into a dataframe, then the value tolist, this can be achieved, but don't know why, 1 g files take 10 g of memory, I can't stand, so I have to optimize the dtype appointed float32, is very big still, Excuse me what method can read in the CSV, at the same time, smaller memory method?
CodePudding user response:
Then write their own, to see if can achieve efficiency, cut a few M for testing first, Code like this
Data_file=open (' data. CSV ', 'r') List1=data_file. Readlines () Data1=[] For l in list1: List2=l.s trip (). The split (', ') Data1. Append (list2)