Class: EdinetCode::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/edinet_code/reader.rb

Defined Under Namespace

Classes: Result

Class Method Summary collapse

Class Method Details

.csv(uncompress_file_path) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/edinet_code/reader.rb', line 23

def self.csv(uncompress_file_path)
  return nil unless File.exist?(uncompress_file_path)
  vals = []
  CSV.open(uncompress_file_path, 'r:cp932') do |csv|
    # ヘッダ部分の2行飛ばす
    2.times{
      csv.shift
    }
    csv.each do |row|
      row.map!{|r| r.encode("utf-8")}
      vals.push(Result.new(
        edinet_code: row[0],
        kind: row[1],
        listed: row[2],
        consolidated: row[3],
        capital: row[4],
        settling_day: row[5],
        submitter: row[6],
        submitter_en: row[7],
        submitter_kana: row[8],
        location: row[9],
        category: row[10],
        code: row[11]
      ))
    end
  end
  vals
end