parceira 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/parceira/reader.rb +10 -4
- data/lib/parceira/version.rb +1 -1
- metadata +1 -1
data/lib/parceira/reader.rb
CHANGED
@@ -53,20 +53,26 @@ module Parceira
|
|
53
53
|
header_data = input_file.readline.to_s.chomp(options[:row_sep]) if options[:headers_included] # Remove header row
|
54
54
|
header_keys = \
|
55
55
|
if options[:headers] == true
|
56
|
-
|
57
|
-
|
56
|
+
begin
|
57
|
+
data = CSV.parse(header_data, self.csv_options)
|
58
|
+
self.parse_header( data )
|
59
|
+
rescue CSV::MalformedCSVError
|
60
|
+
end
|
58
61
|
elsif options[:headers].is_a?(Array)
|
59
62
|
options[:headers]
|
60
63
|
end
|
61
64
|
|
62
65
|
# now on to processing all the rest of the lines in the CSV file:
|
63
66
|
while !input_file.eof? # we can't use f.readlines() here, because this would read the whole file into memory at once, and eof => true
|
64
|
-
values =
|
67
|
+
values = begin
|
68
|
+
parse_values( CSV.parse(input_file.readline.chomp, csv_options) )
|
69
|
+
rescue CSV::MalformedCSVError
|
70
|
+
end
|
65
71
|
if header_keys
|
66
72
|
output << convert_to_hash(header_keys, values)
|
67
73
|
else
|
68
74
|
output << values
|
69
|
-
end
|
75
|
+
end if values
|
70
76
|
end
|
71
77
|
ensure
|
72
78
|
$/ = $/
|
data/lib/parceira/version.rb
CHANGED