Dazimalzahlen plotten
Verfasst: Mittwoch 6. November 2019, 18:46
Hallo, ich habe meine Daten als CSV Datei in folgender Form vorliegen:
9.968503799;299.998;0.004718122;0.004720358
9.968503899;299.998;0.004718122;0.004720358
9.968504099;299.998;0.004718122;0.004720358
9.968504499;299.998;0.004718122;0.004720358
9.968505299;299.998;0.004718122;0.004720358
9.968506899;299.998;0.004718122;0.004720358
bei dem Versuch zu plotten kommt folgende Meldung, hier der Code
import matplotlib.pyplot as plt
import csv
x = []
y = []
with open('Mappe2.csv','r') as csvfile:
plots = csv.reader(csvfile, delimiter=';')
for row in plots:
x.append(int(row[0]))
y.append(int(row[1]))
plt.plot(x,y, label='Loaded from file!')
plt.xlabel('x')
plt.ylabel('y')
plt.title('Interesting Graph\nCheck it out')
plt.legend()
plt.show()
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-13-a4270439472c> in <module>
8 plots = csv.reader(csvfile, delimiter=';')
9 for row in plots:
---> 10 x.append(int(row[0]))
11 y.append(int(row[1]))
12
ValueError: invalid literal for int() with base 10: '9.968503799'
Es scheint an den Dezimalzahlen zu liegen, hat jemand einen Tip? Danke
9.968503799;299.998;0.004718122;0.004720358
9.968503899;299.998;0.004718122;0.004720358
9.968504099;299.998;0.004718122;0.004720358
9.968504499;299.998;0.004718122;0.004720358
9.968505299;299.998;0.004718122;0.004720358
9.968506899;299.998;0.004718122;0.004720358
bei dem Versuch zu plotten kommt folgende Meldung, hier der Code
import matplotlib.pyplot as plt
import csv
x = []
y = []
with open('Mappe2.csv','r') as csvfile:
plots = csv.reader(csvfile, delimiter=';')
for row in plots:
x.append(int(row[0]))
y.append(int(row[1]))
plt.plot(x,y, label='Loaded from file!')
plt.xlabel('x')
plt.ylabel('y')
plt.title('Interesting Graph\nCheck it out')
plt.legend()
plt.show()
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-13-a4270439472c> in <module>
8 plots = csv.reader(csvfile, delimiter=';')
9 for row in plots:
---> 10 x.append(int(row[0]))
11 y.append(int(row[1]))
12
ValueError: invalid literal for int() with base 10: '9.968503799'
Es scheint an den Dezimalzahlen zu liegen, hat jemand einen Tip? Danke