From db7501312d27db2be4ac9efcdcfc3e70d23acc13 Mon Sep 17 00:00:00 2001 From: David Arango Date: Fri, 26 Apr 2013 13:26:46 +0200 Subject: [PATCH] Fixes error when importing xls files XLS loader was crashing when trying to rename columns. Upgrading roo solves the issue. --- Gemfile | 2 +- Gemfile.lock | 14 ++++---------- .../lib/cartodb-importer/preprocessors/xls.rb | 5 ++--- script/xls2csv.rb | 4 ++-- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/Gemfile b/Gemfile index 2991689035..a8b1683a25 100644 --- a/Gemfile +++ b/Gemfile @@ -46,7 +46,7 @@ end # Importer gem "ruby-ole", "1.2.11.3" gem "rchardet19", "1.3.5" -gem "roo", "1.9.7" +gem "roo", "1.11.2" gem "spreadsheet", "0.6.5.9" gem "google-spreadsheet-ruby", "0.1.8" gem "rubyzip", "0.9.9" diff --git a/Gemfile.lock b/Gemfile.lock index fd16ab74a5..d372f51b26 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -62,7 +62,6 @@ GEM xpath (~> 0.1.4) childprocess (0.3.9) ffi (~> 1.0, >= 1.0.11) - choice (0.1.6) chunky_png (1.2.8) coderay (1.0.9) columnize (0.3.6) @@ -128,7 +127,6 @@ GEM addressable (~> 2.2.6) libv8 (3.3.10.4) listen (0.7.3) - log4r (1.1.10) lumberjack (1.0.3) mail (2.4.4) i18n (>= 0.4.0) @@ -219,12 +217,10 @@ GEM rgeo (>= 0.2.8) rollbar (0.9.6) multi_json (~> 1.5) - roo (1.9.7) - choice (>= 0.1.4) - google-spreadsheet-ruby (>= 0.1.5) - nokogiri (>= 1.5.0) + roo (1.11.2) + nokogiri + rubyzip spreadsheet (> 0.6.4) - todonotes (>= 0.1.0) rspec (2.10.0) rspec-core (~> 2.10.0) rspec-expectations (~> 2.10.0) @@ -280,8 +276,6 @@ GEM thor (0.14.6) tilt (1.3.6) timecop (0.3.5) - todonotes (0.1.1) - log4r treetop (1.4.12) polyglot polyglot (>= 0.3.1) @@ -353,7 +347,7 @@ DEPENDENCIES rgeo (= 0.3.2) rgeo-geojson (= 0.2.1) rollbar - roo (= 1.9.7) + roo (= 1.11.2) rspec-rails (= 2.10.1) ruby-ole (= 1.2.11.3) rubyzip (= 0.9.9) diff --git a/lib/importer/lib/cartodb-importer/preprocessors/xls.rb b/lib/importer/lib/cartodb-importer/preprocessors/xls.rb index b2e14d0474..d9f5317552 100644 --- a/lib/importer/lib/cartodb-importer/preprocessors/xls.rb +++ b/lib/importer/lib/cartodb-importer/preprocessors/xls.rb @@ -37,11 +37,11 @@ module CartoDB end #preprocessor_for def xls - fix_carriage_returns_in_headers( Excel.new(origin_path) ) + fix_carriage_returns_in_headers( Roo::Excel.new(origin_path) ) end #xls def xlsx - fix_carriage_returns_in_headers( Excelx.new(origin_path) ) + fix_carriage_returns_in_headers( Roo::Excelx.new(origin_path) ) end #xlsx def ods @@ -51,7 +51,6 @@ module CartoDB def fix_carriage_returns_in_headers(data) g = Array.new data.row(1).each{ |cell| g << cell.gsub('\n', '').strip } - if data.row(1) != g cell_count = 1 diff --git a/script/xls2csv.rb b/script/xls2csv.rb index 42e6633590..8e4e1211ee 100644 --- a/script/xls2csv.rb +++ b/script/xls2csv.rb @@ -15,9 +15,9 @@ else when '.odt' Openoffice.new(ARGV[0]) when '.xls' - Excel.new(ARGV[0]) + Roo::Excel.new(ARGV[0]) when '.xlsx' - Excelx.new(ARGV[0]) + Roo::Excelx.new(ARGV[0]) end s.to_csv("/tmp/#{csv_name}.csv") puts "/tmp/#{csv_name}.csv"