# Script errors

**URL:** <https://www.ruby-forum.com/t/script-errors/113713>\
**Category:** Ruby\
**Created:** [September 4, 2007, 8:43am UTC](https://www.ruby-forum.com/t/script-errors/113713 "2007-09-04T08:43:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [September 4, 2007, 8:43am UTC](https://www.ruby-forum.com/t/script-errors/113713/1 "2007-09-04T08:43:54Z")

</div>

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©[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!

---

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [September 4, 2007, 10:35am UTC](https://www.ruby-forum.com/t/script-errors/113713/2 "2007-09-04T10:35:17Z")

</div>

Hi,

At Tue, 4 Sep 2007 15:43:55 +0900,  
Michael L. 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?

---

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [September 4, 2007, 10:42am UTC](https://www.ruby-forum.com/t/script-errors/113713/3 "2007-09-04T10:42:35Z")

</div>

Nobuyoshi N. wrote:

> Hi,
> 
> At Tue, 4 Sep 2007 15:43:55 +0900,  
> Michael L. 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!

---

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [September 4, 2007, 11:17am UTC](https://www.ruby-forum.com/t/script-errors/113713/4 "2007-09-04T11:17:26Z")

</div>

On 4 Sep 2007, at 17:42, Michael L. wrote:

> 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 G.

Bioinformatics Center  
Kyoto University

---

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [September 4, 2007, 11:10am UTC](https://www.ruby-forum.com/t/script-errors/113713/5 "2007-09-04T11:10:24Z")

</div>

Hi,

At Tue, 4 Sep 2007 17:42:45 +0900,  
Michael L. 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?

---

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [September 4, 2007, 7:03pm UTC](https://www.ruby-forum.com/t/script-errors/113713/6 "2007-09-04T19:03:36Z")

</div>

Alex G. 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
