Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > not sure what is wrong here.

Reply
Thread Tools

not sure what is wrong here.

 
 
Junkone
Guest
Posts: n/a
 
      06-06-2007
i am not sure what is wrong here
tablearr is of type FASTERCSV::TABLE
eachrow is of type FASTERCSV::ROW
as per the fastercsv doc, the table.values_at returns a array.
the array has method .include?<searchcriteria>

def checkduplicates(eachrow,tablearr,indx,criteria)
eachrow.each{|name,valu|
rowdata=tablearr.values_at(indx+criteria)
if(rowdata.include?valu)<<<<<<<<<<<<< ERROR HERE.
puts "match"
end

}

c:/ruby/lib/ruby/gems/1.8/gems/fastercsv-1.2.0/lib/faster_csv.rb:
345:in `==': undefined method `row' for "03":String (NoMethodError)
from scan.rb:7:in `include?'

 
Reply With Quote
 
 
 
 
James Edward Gray II
Guest
Posts: n/a
 
      06-06-2007
On Jun 6, 2007, at 8:30 AM, Junkone wrote:

> i am not sure what is wrong here
> tablearr is of type FASTERCSV::TABLE
> eachrow is of type FASTERCSV::ROW
> as per the fastercsv doc, the table.values_at returns a array.
> the array has method .include?<searchcriteria>
>
> def checkduplicates(eachrow,tablearr,indx,criteria)
> eachrow.each{|name,valu|
> rowdata=tablearr.values_at(indx+criteria)
> if(rowdata.include?valu)<<<<<<<<<<<<< ERROR HERE.
> puts "match"
> end
>
> }
>
> c:/ruby/lib/ruby/gems/1.8/gems/fastercsv-1.2.0/lib/faster_csv.rb:
> 345:in `==': undefined method `row' for "03":String (NoMethodError)
> from scan.rb:7:in `include?'


I'm happy to help debug this, but it would be much easier if I had
some code I could run. Could you try reducing the error to a simple
little script, using included dummy data, that shows the problem?
When I see that, I'm sure I can provide some suggestions.

James Edward Gray II

 
Reply With Quote
 
 
 
 
Junkone
Guest
Posts: n/a
 
      06-06-2007
On Jun 6, 9:50 am, James Edward Gray II <(E-Mail Removed)>
wrote:
> On Jun 6, 2007, at 8:30 AM, Junkone wrote:
>
>
>
>
>
> > i am not sure what is wrong here
> > tablearr is of type FASTERCSV::TABLE
> > eachrow is of type FASTERCSV::ROW
> > as per the fastercsv doc, the table.values_at returns a array.
> > the array has method .include?<searchcriteria>

>
> > def checkduplicates(eachrow,tablearr,indx,criteria)
> > eachrow.each{|name,valu|
> > rowdata=tablearr.values_at(indx+criteria)
> > if(rowdata.include?valu)<<<<<<<<<<<<< ERROR HERE.
> > puts "match"
> > end

>
> > }

>
> > c:/ruby/lib/ruby/gems/1.8/gems/fastercsv-1.2.0/lib/faster_csv.rb:
> > 345:in `==': undefined method `row' for "03":String (NoMethodError)
> > from scan.rb:7:in `include?'

>
> I'm happy to help debug this, but it would be much easier if I had
> some code I could run. Could you try reducing the error to a simple
> little script, using included dummy data, that shows the problem?
> When I see that, I'm sure I can provide some suggestions.
>
> James Edward Gray II- Hide quoted text -
>
> - Show quoted text -


Hello
Thanks for your response. attaching the script and data


data
No,S/W,Day,Month,Year,N1,N2,N3,N4,N5,N6,Bn,Sum
1,Sat,12 ,June,1982,03,11,12,14,41,43,13,124
2,Sat,19 ,June,1982,08,33,36,37,39,41,09,194
3,Sat,26 ,June,1982,06,01,23,24,27,39,34,120
4,Sat,03 ,July,1982,03,09,10,13,20,43,34,98
5,Sat,10 ,July,1982,05,14,21,31,34,47,45,152
6,Sat,17 ,July,1982,08,20,21,25,31,41,33,146
7,Sat,24 ,July,1982,18,25,28,33,36,42,07,182


script
require "faster_csv"
SEARCH_CRITERIA=1

def checkduplicates(eachrow,tablearr,indx,criteria)
eachrow.each{|name,valu|
rowdata=tablearr.values_at(indx+criteria)
if(rowdata.include?valu)
puts "match"
end

}


end


tablearr = FasterCSV.read("c:\\ruby\\testing\\data.txt",
{:headers=>true,:skip_blanks=>true})
tablearr.by_col!()

tablearr.delete("No")
tablearr.delete("S/W")
tablearr.delete("Day")
tablearr.delete("Month")
tablearr.delete("Year")
#puts tablearr
tablearr.by_row!()
tablearr.each_with_index{|eachrow,indx|
checkduplicates(eachrow,tablearr,indx,SEARCH_CRITE RIA)

# puts indx
}


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
First bit of hacked-together code, and not sure where I've gone wrong alex.m.mcpherson@gmail.com Ruby 1 01-17-2009 06:05 AM
sure shot requirement for C++ with Unix Experience !!! sure interviewto day !!! Himayat66@gmail.com ASP .Net 0 02-07-2008 12:40 AM
not sure what is wrong. strange error Junkone Ruby 4 09-15-2006 09:46 PM
not sure what is wrong. seems to look right to me junkone@rogers.com Ruby 1 07-30-2006 04:13 AM
URGENT : I am 100 % sure there is nothing wrong in the ASP code..BUT why is it not working techy techno ASP General 3 02-24-2004 05:54 PM



Advertisments