Guest User

Untitled

a guest
Sep 19th, 2019
114
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ############# Solved.
  2.  
  3. # go throw the rows in the table
  4. rates_table["body"].each { |row|
  5. # the first cell in the row is a descriptor for the other cells
  6. row_description = row.shift["c"]
  7.  
  8. # add the rest of the cells in the row, each as their own record
  9. row.each_with_index { |cell, i|
  10. unique_id = "#{table_id}-#{cell["cellid"]}"
  11. record = {
  12. table_and_cell_id: unique_id,
  13. table_id: table_id,
  14. cell_id: cell["cellid"],
  15. first_column_description: column_descriptions.first,
  16. row_description: row_description,
  17. this_column_description: column_descriptions[i+1],
  18. value: cell["c"]
  19. }
  20.  
  21. @logger.info record[:value]
  22.  
  23.  
  24. if record[:value].include? "as low as"
  25. @logger.info "Found string: as low as"
  26. record[:value] = (record[:value].match /[0-9.]+/)[0]
  27. @logger.info "Transformed value: #{record[:value]}"
  28. end
  29.  
  30.  
  31. @logger.info "Record: #{record}"
  32. records.push record
  33. }
  34. }
RAW Paste Data