Good day to all. There is a large array of data (a couple of millions of such lines):

-0,30273438;-0,06835938; -0,29785156;-0,05371094; -0,28320313;-0,04882813; -0,28808594;-0,06347656; -0,27343750;-0,03417969; -0,24414063;-0,03906250; -0,24414063;-0,01464844; 

I wrote this program:

 import csv with open('202831.dat', newline='') as csvfile: trash = csv.reader(csvfile, delimiter=';') for row in trash: print('.'.join(row)) x.append(float(row[0])) y.append(float(row[1])) 

At the output, I get a large array, but when I try to pull data from it, I get:

could not convert string to float: '-0,30273438'

It is necessary to construct 2 graphs x and y from t , where t is the length of the vector (?) x or y . Unfortunately, the Chukchi is not a programmer, I ask for your help.

  • The problem is that float () expects a stop as a separator, not a comma - retorta

1 answer 1

Replace all commas with dots:

 x.append(float(row[0].replace(",", "."))) y.append(float(row[1].replace(",", "."))) 
  • It helped! Thank you very much) And do not tell me how to build graphs of the number of samples t? Swears at x and y, but have shapes (7,) and (1,) ..... although the length of the vectors is the same - Drakebusher
  • all done, thanks again) - Drakebusher