i'm using spyder to plot some graphe the problem is that i want to avoid the first line and convert the X axis in a format that python could plot. i founded two solution for each probleme, my file format is like this
Heure O3 unit alarm
11:46:35 1.054 ppb
11:46:45 0.9767 ppb
11:46:55 1.172 ppb
11:47:05 1.173 ppb
11:47:15 1.252 ppb
11:47:25 0.813 ppb
11:47:35 1.247 ppb
11:47:45 1.054 ppb
11:47:55 1.721 ppb
11:48:05 1.098 ppb
11:48:15 1.321 ppb
11:48:25 0.4157 ppb
11:48:35 0.856 ppb
11:48:45 0.856 ppb
first solution to avoid the first line:
f = open("filename.txt", "r")
header1 = f.readline()
for line in f:
line = line.strip()
columns = line.split()
time = columns[0]
concentration = float(columns[1])
print time, concentration
but i can not plot it because he is not accepting the format HH:MM:SS
second solution for plotting:
import matplotlib.pyplot as plt
from matplotlib.dates import strpdate2num
import numpy as np
time, val = np.loadtxt("filename.txt",
usecols=(0,1), unpack=True,converters = {0: strpdate2num("%H:%M:%S")})
plt.plot_date(time, val, "r")
plt.show()
it work but i need to delete the first line manually, i'm trying to avoid this step because i will repeat this operation for several txt files.