Hi,
i have a txtfile with a format like that =
AP850KP;INCLIB;E023889;AP013;240107;0730
AP850SD$;INCLIB;E052337;AP013;240107;0730
AP850SDA;INCLIB;E050441;AP013;240107;0730
AP850SDI;INCLIB;E023889;AP013;240107;0730
AP850SDO;INCLIB;E052337;AP013;240107;0730
AP850SDS;INCLIB;E050441;AP013;240107;0730
…
i want to get a collection for every E followed by digits,
so with the example above, i want to get =
collections:
E023889
E052337
E050441
…
each collection should contain datasets with the rest of the line, so
f.e.
E023889 would have =
[AP850KP;INCLIB;AP013;240107;0730,AP850SDI;AP013;240107;0730]
questions=
what kind of collection is the best ? is an array sufficient ?
right now i have =
efas=Array.new
File.open(“mycsvfile”, “r”).each do |line|
if line =~ /(\w+.?);(\w+);(\w+);(\w+);(\w+);(\w+)/
efas<<$3.to_s<<',' unless efas.include?($3.to_s)
end
end
puts efas.to_s.chop
So i have all Ed+, but how to get further ?
Are there better ways as regular expressions ?
Any ideas ?
Regards, Gilbert