# Challenge with FasterCSV

**URL:** <https://www.ruby-forum.com/t/challenge-with-fastercsv/101505>\
**Category:** Ruby\
**Created:** [August 5, 2006, 2:51pm UTC](https://www.ruby-forum.com/t/challenge-with-fastercsv/101505 "2006-08-05T14:51:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 5, 2006, 2:51pm UTC](https://www.ruby-forum.com/t/challenge-with-fastercsv/101505/1 "2006-08-05T14:51:04Z")

</div>

HI  
How can i define the header to be in the 3row of the the array loaded  
After the array is loaded can i redefine the header.

for eg in the following cod  
require “faster\_csv”  
arr\_of\_arrs = FasterCSV.read(“c:\temp\QuoteData.dat”)  
currentPrice=arr\_of\_arrs.values\_at(0)[0][1]  
arr\_of\_arrs.delete\_at(0)  
arr\_of\_arrs.delete\_at(0)

I dont know how to define the header for the arr\_of\_arrs. I a unclear  
after reading the docs

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 5, 2006, 6:42pm UTC](https://www.ruby-forum.com/t/challenge-with-fastercsv/101505/2 "2006-08-05T18:42:20Z")

</div>

On Aug 5, 2006, at 7:50 AM, removed\_email\_address@domain.invalid wrote:

> I dont know how to define the header for the arr\_of\_arrs. I a unclear  
> after reading the docs

I’m sorry, but I don’t think I understand the question well enough to  
answer it. Could you please show a small sample data set and what  
you would like to accomplish?

James Edward G. II

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 6, 2006, 2:46am UTC](https://www.ruby-forum.com/t/challenge-with-fastercsv/101505/3 "2006-08-06T02:46:11Z")

</div>

James Edward G. II wrote:

> > arr\_of\_arrs.delete\_at(0)  
> > arr\_of\_arrs.delete\_at(0)
> > 
> > I dont know how to define the header for the arr\_of\_arrs. I a unclear  
> > after reading the docs
> 
> I’m sorry, but I don’t think I understand the question well enough to  
> answer it. Could you please show a small sample data set and what  
> you would like to accomplish?
> 
> James Edward G. II

A sample data is in this link  
[http://www.geocities.com/murthysuresh/ABC.TXT](http://www.geocities.com/murthysuresh/ABC.TXT)

I am trying to load this file using  
arr\_of\_arrs = FasterCSV.read(“c:\temp\QuoteData.dat”)

I assign the current price using  
currentPrice=arr\_of\_arrs.values\_at(0)[0][1]

I then delete the first two lines of the data as they are not useful  
anymore  
arr\_of\_arrs.delete\_at(0)  
arr\_of\_arrs.delete\_at(0)

Now i want to use the 3rd line that u see in the link as my header for  
the csv records.  
for eg the Calls should refer to the first column, Last Sale for second  
column

I am not sure if this is feasible

Thanks in advance

Seede

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 6, 2006, 5:07pm UTC](https://www.ruby-forum.com/t/challenge-with-fastercsv/101505/4 "2006-08-06T17:07:55Z")

</div>

On Aug 5, 2006, at 7:45 PM, removed\_email\_address@domain.invalid wrote:

> A sample data is in this link  
> [http://www.geocities.com/murthysuresh/ABC.TXT](http://www.geocities.com/murthysuresh/ABC.TXT)

> I am not sure if this is feasible

Sure it is. Here’s the skeleton code to get you going:

require “faster\_csv”

File.open(“ABC.TXT”) do |file|  
current\_price = file.gets.parse\_csv(:row\_sep =\> “\r\r\n”)[1]  
file.gets  
FCSV(file, :row\_sep =\> “\r\r\n”, :headers =\> true) do |csv|  
csv.each do |row|  
# … use current\_price and row here …  
end  
end  
end

You may not need those odd :row\_sep settings. The file I downloaded  
had very odd line endings, but that may have been a web server or  
browser mucking with the data along the way.

Hope that helps.

James Edward G. II
