lib/gorillib/model/serialization/csv.rb in gorillib-0.4.2 vs lib/gorillib/model/serialization/csv.rb in gorillib-0.5.0

- old
+ new

@@ -19,12 +19,14 @@ # @raise [Gorillib::Model::RawDataMismatchError] if a line has too many or too few fields # @yield an object instantiated from each line in the file. def each_in_csv(filename, options={}) filename = Pathname.path_to(filename) options = csv_options.merge(options) + # pop_headers = options.delete(:pop_headers) num_fields = options.delete(:num_fields){ (fields.length .. fields.length) } raise ArgumentError, "The :headers option to CSV changes its internal behavior; use 'pop_headers: true' to ignore the first line" if options[:headers] + # CSV.open(filename, options) do |csv_file| csv_file.shift if pop_headers csv_file.each do |tuple| next if tuple.empty? unless num_fields.include?(tuple.length) then raise Gorillib::Model::RawDataMismatchError, "yark, spurious fields: #{tuple.inspect}" ; end