Class: Slcsp::SlcspParser
- Inherits:
-
Object
- Object
- Slcsp::SlcspParser
- Defined in:
- lib/slcsp/slcsp_parser.rb
Overview
parses the csv with slcsp zips and yeild line by line for external use
Instance Method Summary collapse
- #headers_line ⇒ Object
-
#initialize(path) ⇒ SlcspParser
constructor
A new instance of SlcspParser.
- #parse_each(&block) ⇒ Object
Constructor Details
#initialize(path) ⇒ SlcspParser
Returns a new instance of SlcspParser.
8 9 10 |
# File 'lib/slcsp/slcsp_parser.rb', line 8 def initialize(path) @path = path end |
Instance Method Details
#headers_line ⇒ Object
22 23 24 25 26 27 |
# File 'lib/slcsp/slcsp_parser.rb', line 22 def headers_line f = File.open(@path) headers = f.gets f.close headers end |
#parse_each(&block) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/slcsp/slcsp_parser.rb', line 12 def parse_each(&block) return unless block_given? File.open(@path) do |file| CSV.foreach(file, headers: true) do |row| block.call row end end end |