79167837

Date: 2024-11-07 19:29:10
Score: 0.5
Natty:
Report link

Read with a foreach, so you are processing line by line. each line is in some variable in a do loop and parse the string by the begin and end positions. Remember that ruby starts arrays at zero not one.

say your fields above are: 2-bytes field1 2-bytes field2 3-bytes field3 ...

File.foreach(filename) do |line| field1 = line[0,1] field2 = line[2,3] field3 = line[4,6] ...

--call a database and write a row? --do what you want with the data like build a dictionary?

end

Inside the do loop parse each row by treating the string as an array: remember ruby arrays start at zero

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Contains question mark (0.5):
Posted by: sean lynch