python - Plotting data from input file from command line -


I have given a data file named "density_air.dat" and I have to take data from each column and put them in In my lists (i.e. tList will hold values ​​in the column starting with "-10") and the density will be assumed in the column starting with "1.341". The lists need to be conspicuously then I want to pop up the lists with this data Having trouble ... Any help?

  to scitools.std import * import sys pylab Import in the form of the enfile = sys.argv [-1] f = open (inFile, 'r') for X range (4): f.readline () tList = [] density = [] line in f For: word = line.split () in words in x: tList.append (word [x]) density .append (word [x]) f.close () conspiracy (tList, density)   

The data file is:

  Density of air at different temperatures in 1 hour, 1 atm pressure # Column 1: Celsius degree temperature # Column 2: density in kg / m ^ 3 -10 1.341 -5 1.316 0 1.2 9 5 1.2 1.2 9 10 1.247 15 1.225 20 1.204 25 1.184 30 1.164 # Source: Wikipedia (Search queries Density)  

There is a numpy function called < Code> loadtxt which load ascii files in the arrays: import as np import plat import sys in matplotlib.pylab File = sys.argv [-1] temperature, density = np.logtext (infile, unpack = true) plt.plot (temperature, density, 'to') plt.show ()

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -