I need help with graphs in python (2.7.3.1)

Discussion in 'Python' started by hevymetl07@gmail.com, Dec 18, 2012.

  1. Guest

    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!
    , Dec 18, 2012
    #1
    1. Advertising

  2. Thomas Bach Guest

    Hi,

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

    On Tue, Dec 18, 2012 at 03:29:49AM -0800, wrote:
    > 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
    Thomas Bach, Dec 18, 2012
    #2
    1. Advertising

  3. Terry Reedy Guest

    On 12/18/2012 6:29 AM, wrote:
    > 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).

    --
    Terry Jan Reedy
    Terry Reedy, Dec 18, 2012
    #3
  4. On Tue, 18 Dec 2012 13:20:25 +0100, Thomas Bach
    <-mainz.de> declaimed the following in
    gmane.comp.python.general:

    > 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 | **************
    --
    Wulfraed Dennis Lee Bieber AF6VN
    HTTP://wlfraed.home.netcom.com/
    Dennis Lee Bieber, Dec 18, 2012
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    0
    Views:
    469
    Guest
    Apr 30, 2004
  2. rhmd
    Replies:
    9
    Views:
    664
    Pat Bills
    Oct 27, 2003
  3. Douglas F. Calvert

    graphs in python...

    Douglas F. Calvert, Dec 3, 2003, in forum: Python
    Replies:
    2
    Views:
    536
    Aaron Watters
    Dec 4, 2003
  4. kbass
    Replies:
    2
    Views:
    404
    Josiah Carlson
    Feb 6, 2004
  5. John Hunter
    Replies:
    3
    Views:
    390
    Jorl Shefner
    Aug 26, 2004
Loading...

Share This Page