I have a text file containing a number of columns and rows, with a variety of data types. I would like to read the file in python and plot the values by selecting the columns. My file looks like this:
time column1 column2 column3 column4 column5 column6 column7
100.035 6.667252E+00 -4.106210E+00 -1.577542E-02 4.090584E+00 -3.699584E-01 -6.998253E-02 -6.699544E-01
100.075 6.776713E+00 -4.347899E+00 -1.791951E-02 4.329726E+00 -3.699584E-01 -6.998253E-02 -6.699544E-01
100.115 6.806808E+00 -4.451121E+00 -1.886022E-02 4.432934E+00 -3.699584E-01 -6.998253E-02 -6.699544E-01
100.155 6.826516E+00 -4.534202E+00 -1.924360E-02 4.513488E+00 -3.699584E-01 -6.998253E-02 -6.699544E-01
100.195 6.890967E+00 -4.962194E+00 -1.946191E-02 4.943943E+00 -3.699584E-01 -6.998253E-02 -6.699544E-01
100.235 6.961544E+00 -5.430468E+00 -1.924892E-02 5.409640E+00 -3.699584E-01 -6.998253E-02 -6.699544E-01
I tried reading the file as mentioned here and here and also tried some pattern-based delimited codes as here. So far the output from the code below has all the columns cramped-up at first_columns
as listed values
.
import csv
with open ('mps50.txt', 'r') as f:
first_column = [row[0] for row in csv.reader(f,delimiter='\t')]
But first_column
is a list and I can't think of how to use this further that can help me plot the values. Can you guide me on how to look to do this? Some samples or a link would be helpful.