Class: RedshiftConnector::Reader::RedshiftCSV
- Defined in:
- lib/redshift_connector/reader/redshift_csv.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: ScanBuffer
Constant Summary
Constants inherited from Abstract
Class Method Summary collapse
Instance Method Summary collapse
- #each_row ⇒ Object (also: #each)
-
#initialize(f) ⇒ RedshiftCSV
constructor
- f
-
IO.
- #read_row ⇒ Object
Methods inherited from Abstract
declare_reader, get_reader_class
Constructor Details
#initialize(f) ⇒ RedshiftCSV
- f
-
IO
16 17 18 19 |
# File 'lib/redshift_connector/reader/redshift_csv.rb', line 16 def initialize(f) @f = f @s = ScanBuffer.new(@f) end |
Class Method Details
.data_object?(key) ⇒ Boolean
11 12 13 |
# File 'lib/redshift_connector/reader/redshift_csv.rb', line 11 def self.data_object?(key) /\.csv(?:\.|\z)/ =~ File.basename(key) end |
Instance Method Details
#each_row ⇒ Object Also known as: each
21 22 23 24 25 26 |
# File 'lib/redshift_connector/reader/redshift_csv.rb', line 21 def each_row s = @s while row = parse_row(@s) yield row end end |
#read_row ⇒ Object
30 31 32 33 |
# File 'lib/redshift_connector/reader/redshift_csv.rb', line 30 def read_row return nil if @s.eof? parse_row(@s) end |