This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
..., -0.078, -0.077, -0.075, -0.074, -0.072, -0.071, -0.07, -0.069, -0.068, -0.067 | |
, -0.066, -0.065, -0.065, -0.064, -0.063, -0.062, -0.061, -0.06, -0.058, -0.057, | |
-0.056, -0.054, -0.052, -0.051, -0.049, -0.047, -0.046, -0.044, -0.043, -0.041, | |
-0.04, -0.039, -0.038, -0.037, -0.036, -0.035, -0.034, -0.033, -0.032, -0.031, | |
-0.03, -0.029, -0.027, -0.026, -0.025, -0.024, -0.023, -0.021, -0.02, -0.019, -0 | |
.018, -0.017, -0.016, -0.014, -0.013, -0.013, -0.012, -0.011, -0.01, -0.009, -0. | |
008, -0.008, -0.007, -0.006, -0.006, -0.005, -0.004, -0.004, -0.003, -0.003, -0. | |
003, "-2E-3", "-2E-3", "-2E-3", "-1E-3", "-1E-3", "-1E-3", 0, 0, 0, 0, 0, "1E-3" | |
, "1E-3", "1E-3", "1E-3", 0, 0, 0, 0, 0, "-1E-3", "-1E-3", "-1E-3", "-1E-3", "-1 | |
E-3", "-1E-3", "-1E-3", "-1E-3", 0, 0, "1E-3", "2E-3", 0.003, 0.004, 0.005, 0.00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubyXL' | |
class Kincom | |
def initialize(file, name) | |
@filename = find_filename(file) | |
@subject = name | |
xlsx_sheets = load(file) #Returnerer object med sheets | |
create_data_hash(xlsx_sheets) #Returnerer object (hash) med hvert spark og dets rådata | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_values(sheets) | |
sheets.flat_map do |sheet| | |
array = Array.new | |
array << sheet.flat_map do |row| | |
row ? row.cells.map { |cell| cell.value if cell } : [] | |
end | |
return array | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def retrieve_data(sheets) | |
array = get_values(sheets) | |
p array | |
end | |
def get_values(sheets) | |
sheets.each do |s| | |
puts "Working..." | |
s.each do |row| unless row.nil? | |
row.cells.map do |cell| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Åbner excel-filen | |
xlsx = Roo::Spreadsheet.open(filename) | |
#Loader alle ark i et array | |
sheetArray = xlsx.sheets | |
sheetArray.each_with_index { |sheet, i| | |
@volt_raw + i = xlsx.sheet(sheet).column(2) | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Started POST "/subjects" for ::1 at 2016-05-06 13:30:00 +0200 | |
Processing by SubjectsController#create as HTML | |
Parameters: {"utf8"=>"V", "authenticity_token"=>"NxFf40TMU9j3Yj6/0a0kQlvpGREHgckCo2XYCfpMmx3gQc9Pzcy9IUMcOIUBDw/Lwfix3oX+BqhY8DrSa/NC4w==", "subject"=>{"name"=>"dasda", "sex"=>"dsa", "i | |
nitial"=>"asda", "email"=>"aasd@dasdsada.dk", "phone"=>"124141241", "born_on"=>"1988-06-01", "scale_weight"=>"252.0", "scale_height"=>"146.0", "medicine"=>"", "known_disease"=>"", "family | |
_disposition"=>"", "other"=>""}, "commit"=>"Save Subject"} | |
(0.0ms) begin transaction | |
Subject Exists (0.0ms) SELECT 1 AS one FROM "subjects" WHERE "subjects"."initial" = 'asda' LIMIT 1 | |
Subject Exists (0.0ms) SELECT 1 AS one FROM "subjects" WHERE "subjects"."email" = 'aasd@dasdsada.dk' LIMIT 1 | |
Subject Exists (0.0ms) SELECT 1 AS one FROM "subjects" WHERE "subjects"."phone" = '124141241' LIMIT 1 | |
(0.0ms) rollback transaction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Model: | |
class Subject < ActiveRecord::Base | |
validates :name, :sex, :initial, :phone, :born_on, presence: true | |
validates :initial, :email, :phone, uniqueness: true, unless: :skip_unique_validation | |
validates :phone, format: { with: /\d/, | |
message: "allows only numbers" } | |
attr_accessor :skip_unique_validation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#The model section: | |
class Subject < ActiveRecord::Base | |
validates :name, :sex, :initial, :phone, :born_on, presence: true | |
validates :initial, :email, :phone, uniqueness: true, unless: :skip_unique_validation | |
validates :phone, format: { with: /\d/, | |
message: "allows only numbers" } | |
attr_accessor :skip_unique_validation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
workbook = RubyXL::Parser.parse("testdb.xlsx") | |
worksheet = workbook[0] | |
worksheet.each do |row| | |
val = row[0].value | |
puts val | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
workbook = RubyXL::Parser.parse("testdb.xlsx") | |
worksheet = workbook[0] | |
puts worksheet[0].size.to_s | |
worksheet.each do |row| | |
val = row[0].value | |
if val != nil | |
puts val.to_s | |