Challenge with FasterCSV

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

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 Gray II

···

On Aug 5, 2006, at 7:50 AM, junkone@rogers.com wrote:

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)

I dont know how to define the header for the arr_of_arrs. I a unclear
after reading the docs

James Edward Gray II wrote:

> 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

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 Gray II

A sample data is in this link

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

···

On Aug 5, 2006, at 7:50 AM, junkone@rogers.com wrote:

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 Gray II

···

On Aug 5, 2006, at 7:45 PM, junkone@rogers.com wrote:

A sample data is in this link
Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos

I am not sure if this is feasible