Class: RedshiftCsvFile
- Inherits:
-
Object
- Object
- RedshiftCsvFile
- Defined in:
- lib/redshift_csv_file.rb
Overview
Reads CSV file generated by Redshift UNLOAD statement (with option ADDQUOTES ESCAPE). UNLOAD escapes data by ‘' (backslash character), we cannot use standard CSV class.
Defined Under Namespace
Classes: MalformedCSVException, ScanBuffer
Instance Method Summary collapse
- #each_row ⇒ Object (also: #each)
-
#initialize(f) ⇒ RedshiftCsvFile
constructor
- f
-
IO.
- #read_row ⇒ Object
Constructor Details
#initialize(f) ⇒ RedshiftCsvFile
- f
-
IO
9 10 11 12 |
# File 'lib/redshift_csv_file.rb', line 9 def initialize(f) @f = f @s = ScanBuffer.new(@f) end |
Instance Method Details
#each_row ⇒ Object Also known as: each
14 15 16 17 18 19 |
# File 'lib/redshift_csv_file.rb', line 14 def each_row s = @s while row = parse_row(@s) yield row end end |
#read_row ⇒ Object
23 24 25 26 |
# File 'lib/redshift_csv_file.rb', line 23 def read_row return nil if @s.eof? parse_row(@s) end |