Taking the floating point distances and plotting histogram
Fredrik Lundh
fredrik at pythonware.com
Wed Jul 23 17:11:11 EDT 2008
aditya shukla wrote:
> I have a program whose output is stored in a text file , say test.txt
> eg.
> 0\9\10\11|0.50|c:\windows\apppatch/AcLayers.dll
> 0\9\10\11|0.50|c:\windows\apppatch/AcRedir.dll
> 0\9\10|0.66|c:\windows\apppatch/AcSpecfc.dll
> 0\9|0.83|c:\windows\apppatch/iebrshim.dll
>
> After reading this text file i need to extract the float point values
> from each line ie , 0.50,0.50,0.66.0.83 <http://0.66.0.83> respectively
> in this case, till the end of the file is reached and then i need to
> plot a histogram based on these values .
Extracting is easy; you can do something like
data = []
for line in open("test.txt"):
line = line.split("|")
data.append(float(line[1]))
(or maybe use the csv module with a custom separator)
Plotting is a bit different -- there are many ways to do that, depending
on where and how you want to display that histogram (on a website, in a
window on your machine, in a PDF file, ...), but most solutions require
additional libraries. Here's one such library:
http://matplotlib.sourceforge.net/
</F>
More information about the Python-list
mailing list