Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,694 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,311 people online right now. Registration is fast and FREE... Join Now!




Parsing text data into an array

 
Reply to this topicStart new topic

Parsing text data into an array, using ruby I/O to convert structured text into usable numberical data

cthulhu
post 17 Jun, 2008 - 09:37 AM
Post #1


New D.I.C Head

*
Joined: 17 Jun, 2008
Posts: 1

Hey total ruby n00b here...
I'm having trouble with parsing data into ruby for statistical analysis.

The data looks like this:
32 0 0 0 0 0 0 0 0 8412803500 0 0 0 0 0 0 0 46655166 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 240554000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85321000 0 0 0 0 0 0 0 479719000 0 0 0 97823285 283432000 0 73887750 0 0 157225000 88659750 285211000 70285000 0 161747000 161167000 234739666 120400000 300083000 0 0 202327250 111865000 183127000 0 161027000 0 0 0

33 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

I need to store the index of the entry, in this case 32 and 33, as the name of the 2 Dimensional array (array of arrays as ruby handles it?) and then each value (alot of zeros in the case of 33) as a unique entry. The format is plain tyext right now and I have had no luck using File.readline

For some reason this does NOT work, the array dimensions do not match expected structure:
elsif /aqua_t/=~(files_to_parse[i])
line_counter = 0
line = File.readlines(files_to_parse[i]).each do |line|
line.each{|x| x.to_i}
raw_data_t[line_counter]=line.split
aqua = [0]
line_counter+=1
end#ends block over lines


Any advice would be much appreciated.
--m
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 07:47AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month