script errors

Discussion in 'Ruby' started by Michael Linfield, Sep 4, 2007.

  1. require 'rubygems'
    require 'ruport'
    require 'ruport/util'
    require 'date'
    require 'optparse'


    opts = OptionParser.new do |opts|
    opts.on("-h", "--help", "Displays this help.") do |a|
    puts opts
    end
    opts.on("-s", "--startdate", "Determines what start date to use.") do
    |b|
    @startdate = Date.new(*ParseDate.parsedate(b)[0,3])
    end
    opts.on("-e", "--enddate", "Determines what end date to use.") do |c|
    @enddate = Date.new(*ParseDate.parsedate(c)[0,3])
    end
    opts.on("-o", "--output", "Specify Output format: svg|pdf|jpg") do |d|
    if ARGV = svg
    saveinput = GraphReport.generate{|r| r.save_as("Reportgraph.svg")}
    elsif ARGV = pdf
    #get pdf gem to output to pdf(ruport might have it included)
    end
    end
    end

    opts.parse!(ARGV)

    result = (@startdate..@enddate).to_a
    range = result.size

    class GraphReport < Ruport::Report
    renders_as_graph

    def generate

    verizondat = []
    qwestdat = []
    level3dat = []
    attdat = []
    sprintdat = []
    data = File.readlines("data.csv")
    head = data[0]
    verizondat = data.grep(/Verizon/)
    qwestdat = data.grep(/Qwest/)
    level3dat = data.grep(/Level3/)
    attdat = data.grep(/AT\&T/)
    sprintdat = data.grep(/Sprint/)
    csv = ([head] + data).join

    table = Ruport::Data::Table.parse(csv)

    graph = Ruport::Graph:)column_names => #the 15 graph points by average

    graph.add_line verizondat.column('AVERAGE').map{|x|
    x.grep(/@startdate..@enddate/).to_i}, :name=> "Verizon"
    graph.add_line qwestdat.column('AVERAGE').map{|x|
    x.grep(/@startdate..@enddate/).to_i}, :name=> "Qwest"
    graph.add_line level3dat.column('AVERAGE').map{|x|
    x.grep(/@startdate..@enddate/).to_i}, :name=> "Level3"
    graph.add_line attdat.column('AVERAGE').map{|x|
    x.grep(/@startdate..@enddate/).to_i}, :name=> "AT&T"
    graph.add_line sprintdat.column('AVERAGE').map{|x|
    x.grep(/@startdate..@enddate/).to_i}, :name=> "Sprint"
    end
    end

    return graph



    GraphReport.generate{|r| r.save_as("graph.svg")}

    ##############
    OUTPUT:

    ruby reportgraph.rb
    reportgraph.rb:55: syntax error, unexpected tIDENTIFIER, expecting ')'
    graph.add_line verizondat.column('AVERAGE').map{|x|
    x.grep(/@startdate..@enddate/).to_i}, :name=> "Verizon"
    ^
    reportgraph.rb:55: syntax error, unexpected ',', expecting kEND
    graph.add_line verizondat.column('AVERAGE').map{|x|
    x.grep(/@startdate..@enddate/).to_i}, :name=> "Verizon"

    ###############

    all the commented objects also need fixing if anyone wants to throw
    suggestions at me while i work on it over the night.

    Much thanks!
    --
    Posted via http://www.ruby-forum.com/.
     
    Michael Linfield, Sep 4, 2007
    #1
    1. Advertising

  2. Hi,

    At Tue, 4 Sep 2007 15:43:55 +0900,
    Michael Linfield wrote in [ruby-talk:267464]:
    > graph = Ruport::Graph:)column_names => #the 15 graph points by average


    The paren in this line doesn't seem closed, and you may forget
    qoutes?

    --
    Nobu Nakada
     
    Nobuyoshi Nakada, Sep 4, 2007
    #2
    1. Advertising

  3. Nobuyoshi Nakada wrote:
    > Hi,
    >
    > At Tue, 4 Sep 2007 15:43:55 +0900,
    > Michael Linfield wrote in [ruby-talk:267464]:
    >> graph = Ruport::Graph:)column_names => #the 15 graph points by average

    >
    > The paren in this line doesn't seem closed, and you may forget
    > qoutes?


    lol thanks, now however i run upon a second error, line 29

    result = (@startdate..@enddate)

    ####
    OUTPUTS:

    reportgraph.rb:29: bad value for range (ArgumentError)
    ####

    fun timez.
    any ideas?

    Thanks!
    --
    Posted via http://www.ruby-forum.com/.
     
    Michael Linfield, Sep 4, 2007
    #3
  4. Hi,

    At Tue, 4 Sep 2007 17:42:45 +0900,
    Michael Linfield wrote in [ruby-talk:267482]:
    > result = (@startdate..@enddate)
    >
    > ####
    > OUTPUTS:
    >
    > reportgraph.rb:29: bad value for range (ArgumentError)


    Maybe, one of them (or both) is nil?

    --
    Nobu Nakada
     
    Nobuyoshi Nakada, Sep 4, 2007
    #4
  5. On 4 Sep 2007, at 17:42, Michael Linfield wrote:

    > Nobuyoshi Nakada wrote:
    >> Hi,
    >>
    >> At Tue, 4 Sep 2007 15:43:55 +0900,
    >> Michael Linfield wrote in [ruby-talk:267464]:
    >>> graph = Ruport::Graph:)column_names => #the 15 graph points by
    >>> average

    >>
    >> The paren in this line doesn't seem closed, and you may forget
    >> qoutes?

    >
    > lol thanks, now however i run upon a second error, line 29
    >
    > result = (@startdate..@enddate)
    >
    > ####
    > OUTPUTS:
    >
    > reportgraph.rb:29: bad value for range (ArgumentError)
    > ####
    >
    > fun timez.
    > any ideas?
    >
    > Thanks!


    What options did you call the script with? Whatever, your use of
    OptionParser is wrong. You are asking for date options with no
    arguments where you should be asking for arguments:

    opts.on("-s", "--startdate", "Determines what start date to use.") do

    Should be:

    opts.on("-s", "--startdate DATE", "Determines what start date to
    use.") do

    And the same for the end date and output options. Check the
    OptionParser docs. There are other bugs in there as well: "ARGV =
    svg" should surely be "d = 'svg'" for instance.

    Alex Gutteridge

    Bioinformatics Center
    Kyoto University
     
    Alex Gutteridge, Sep 4, 2007
    #5
  6. Alex Gutteridge wrote:

    >
    > What options did you call the script with? Whatever, your use of
    > OptionParser is wrong. You are asking for date options with no
    > arguments where you should be asking for arguments:
    >
    > opts.on("-s", "--startdate", "Determines what start date to use.") do
    >
    > Should be:
    >
    > opts.on("-s", "--startdate DATE", "Determines what start date to
    > use.") do
    >
    > And the same for the end date and output options. Check the
    > OptionParser docs. There are other bugs in there as well: "ARGV =
    > svg" should surely be "d = 'svg'" for instance.


    well after fixing those few flaws i get a huge nomethoderror from the
    method .column such as verizondat.column ...understandable because it
    is actually supposed to use table.column but in fact table is tied to

    table = Ruport::Data::Table.parse(csv)

    which parses the data, not the grep'd array..so i guess my question now
    would be how do i perform the same function except on the grep'd data?

    -Thanks
    --
    Posted via http://www.ruby-forum.com/.
     
    Michael Linfield, Sep 4, 2007
    #6
    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. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,027
    Mark Goldin
    Jan 17, 2004
  2. SenthilVel
    Replies:
    0
    Views:
    976
    SenthilVel
    Jun 7, 2006
  3. George1776

    Out-of-memory errors and caching errors.

    George1776, Aug 28, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    1,362
    George1776
    Sep 14, 2006
  4. Lance Wynn
    Replies:
    1
    Views:
    1,916
    Lance Wynn
    Feb 3, 2008
  5. yawnmoth
    Replies:
    97
    Views:
    4,800
    Bent C Dalager
    Feb 27, 2009
Loading...

Share This Page