also so langsam bin ich am Verzweifeln und brauche Hilfe.
Ich habe eine txt-Datei mit zwei Spalten. Diese Datei lese ich ein mache daraus zwei Spalten und möchte die dann ploten.
So sieht die txt-Datei aus:
Zeit Messwerte
1 5
2 6
3 7
4 8
5 2
6 9
7 3
8 4
9 8
10 6
Hier ist der Programm-Code:
Code: Alles auswählen
from pylab import *
from pandas import *
file = open('Messwerte.txt')
line = read_table('Messwerte.txt',skiprows=0,sep='\t*',engine ='python')
x = []; y = []
for line in file:
xval , yval = line.split()
x.append(float(xval))
y.append(float(yval))
plt.xlabel('Zeit [ms]')
plt.ylabel('Kraft')
plot(x,y)
Ich bekomme folgende Fehlermeldung:
ValueError: could not convert string to float: 'Zeit'
Wobei ich das eigentlich mit skiprows umgehen möchte.
Das merkürdigste ist wenn man nun file = open('Messwerte.txt') auskommentiert funktioniert das Programm einmal. Beim mehrmaligem Ausführen mit der Zeile auskommentiert, kommt keine Fehlermeldung jedoch fehlt der Graph.
Vielen Dank im Vorraus für Anregungen,Tipps und Lösungen