I need help with graphs in python (2.7.3.1)

H

hevymetl07

Hi there, I hope that there is someone willing to help me out, I need to generate a graph in Python 2.7.3.1, but I am not that skilled with Python and I am completely stuck :(

I had to make a .CSV file from my Windows system logs (already did that), and the following steps must bw written in the form of a Python 2.7.3.1 script.

These are some steps I need to do first before creating the graph:
- Get the name of a CSV file from an ini file,
- Next, read a line from this CSV file,
- Increase a variable depending on the Log level (information, warning, error, critical),
- Read the next line,
- Then I need to print these results in a Graph.

I really hope that there is someone there to help me out, and many thanks in advance for all your help!
 
T

Thomas Bach

Hi,

Most of the tasks you have to do can be achieved quite easily with the
standard library (except the plotting).

These are some steps I need to do first before creating the graph:
- Get the name of a CSV file from an ini file,
Have a look at the ConfigParser module[1],
- Next, read a line from this CSV file,
well, the csv module[2] apparently is a good choice for that,
- Increase a variable depending on the Log level (information,
- warning, error, critical),
you maybe want to use collections.counter for that[3]. Anyways, I
think matplotlib can handle the counting for you…
- Read the next line,
this is just iteration over the csv instance you created with your file
- Then I need to print these results in a Graph.
I use matplotlib for this purpose, have a look at their gallery[4] to
decide what kind of plot best fits your needs.


I'd recommend to install ipython and start playing around with the
modules I just told you. If you are stuck somewhere read the
documentation properly (it's actually all in there) and come back
again if you cannot come up with a solution.


Hope this helps,
Thomas Bach.

Footnotes:
[1] http://docs.python.org/2/library/configparser.html

[2] http://docs.python.org/2/library/csv.html

[3] http://docs.python.org/2/library/collections.html#collections.Counter

[4] http://matplotlib.org/gallery.html
 
T

Terry Reedy

Hi there, I hope that there is someone willing to help me out, I need
to generate a graph in Python 2.7.3.1,

There is only 2.7.3, no 2.7.3.1, at least not officially.
I had to make a .CSV file from my Windows system logs (already did
that), and the following steps must bw written in the form of a
Python 2.7.3.1 script.

These are some steps I need to do first before creating the graph: -
Get the name of a CSV file from an ini file, - Next, read a line from
this CSV file, - Increase a variable depending on the Log level
(information, warning, error, critical), - Read the next line, - Then
I need to print these results in a Graph.

It sounds like your data consist of 4 counts. If so, you can easily make
a simple bar plot with characters

Log level Number Plot (x = 10)
---------- ------ -----------------------------------------------------
infomation 386 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
warning 97 xxxxxxxxxx
error 5 x
critical 23 xxx

The main problem is to compute the scaling factor from the data.
You also have to decide on the rounding (I rounded up).
 
D

Dennis Lee Bieber

Hi,

Most of the tasks you have to do can be achieved quite easily with the
standard library (except the plotting).
Since it sounds like the output is going to be a bar-chart, even
that could be done with the standard library... Based on the counts,
set the highest count to map to, say 60 (characters), scale the other
counts proportionately, then generate a display of (use fixed pitch)

info | ********************
warn | *****************************************
error | *******
crit | **************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top