Module: XlsParser
Class Method Summary collapse
-
.load_meta_fields(file) ⇒ Object
A few rules about Excel files: 1.
Class Method Details
.load_meta_fields(file) ⇒ Object
A few rules about Excel files:
-
.xls only, this can’t accept .xlsx
-
There should be no empty cells in the header row of a sheet (first row)
-
For good form, there shouldn’t be any subsequent rows that are longer than the header row
-
There should not be any duplicate cell names in the header row
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/vardb/xls_parser.rb', line 10 def XlsParser.(file) s = Roo::Excel.new(file) s.default_sheet = s.sheets.first columns = 1 until s.cell(1, columns).nil? columns += 1 end counter = 1 = [] columns.times do |counter| if s.cell(1, counter).nil? << ", empty#{counter}" else << ", #{s.cell(1, counter).to_s.gsub(/\s+/, "").gsub("-","").gsub("(","").gsub(")","").gsub(".","").gsub("/","")}" end counter += 1 end return end |