Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.7.0 breaking on reading CSV files from S3 or local folder #378

Closed
jotterlei opened this issue Jan 19, 2017 · 2 comments
Closed

2.7.0 breaking on reading CSV files from S3 or local folder #378

jotterlei opened this issue Jan 19, 2017 · 2 comments

Comments

@jotterlei
Copy link

After updating from 2.5.1 to 2.7.1 a CSV reading with Roo broke in our application. I traced it to 2.6.0 working fine and then 2.7.0 breaking.

Stack trace

Errno::ENOENT - No such file or directory @ rb_sysopen - https://BUCKET.s3.amazonaws.com/uploads/d/attachment/file/45/roster_01012017.csv:
  /Users/jotterlei/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/csv.rb:1265:in `open'
  /Users/jotterlei/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/csv.rb:1339:in `read'
  /Users/jotterlei/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/csv.rb:1344:in `readlines'
  roo (2.7.0) lib/roo/csv.rb:101:in `set_row_count'
  roo (2.7.0) lib/roo/csv.rb:66:in `read_cells'
  roo (2.7.0) lib/roo/base.rb:145:in `row'
  app/services/import_roster.rb:41:in `read_file'

Contents of roster_01012017.csv Stack trace

FirstName,MiddleName,LastName
Chuck,,Evans
Robby,,Jones
Jack,,Nicholas
Franz,,Ouimet
Daniel,,Duval

Rails console showing error and stack trace

[5] pry(main)> Roo::Spreadsheet.open("https://cloudscoring.s3.amazonaws.com/uploads/d/attachment/file/45/roster_01012017.csv", extension: "csv").row(1)
Errno::ENOENT: No such file or directory @ rb_sysopen - https://BUCKET.s3.amazonaws.com/uploads/d/attachment/file/45/roster_01012017.csv
from /Users/jotterlei/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/csv.rb:1265:in `initialize'
[6] pry(main)> wtf?
Exception: Errno::ENOENT: No such file or directory @ rb_sysopen - https://BUCKET.s3.amazonaws.com/uploads/d/attachment/file/45/roster_01012017.csv
--
0: /Users/jotterlei/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/csv.rb:1265:in `initialize'
1: /Users/jotterlei/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/csv.rb:1265:in `open'
2: /Users/jotterlei/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/csv.rb:1265:in `open'
3: /Users/jotterlei/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/csv.rb:1339:in `read'
4: /Users/jotterlei/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/csv.rb:1344:in `readlines'
5: /Users/jotterlei/.rvm/gems/ruby-2.3.1/gems/roo-2.7.0/lib/roo/csv.rb:101:in `set_row_count'
6: /Users/jotterlei/.rvm/gems/ruby-2.3.1/gems/roo-2.7.0/lib/roo/csv.rb:66:in `read_cells'
7: /Users/jotterlei/.rvm/gems/ruby-2.3.1/gems/roo-2.7.0/lib/roo/base.rb:145:in `row'
8: (pry):3:in `__pry__'
9: /Users/jotterlei/.rvm/gems/ruby-2.3.1/gems/pry-0.10.4/lib/pry/pry_instance.rb:355:in `eval'
[7] pry(main)> 

@thbar
Copy link

thbar commented Feb 1, 2017

Potentially related to #374.

@matiasgarcia
Copy link

Has anyone found a workaround for this? Looks like downgrading roo to 2.6.0 works, but 2.7.0 is way more performant than 2.6.0

chopraanmol1 added a commit to chopraanmol1/roo that referenced this issue Oct 5, 2018
### Summary

Fixes roo-rb#378 and roo-rb#374 (Introduced in roo-rb#368)

### Benchmark

```
file_name = 'test/files/Bibelbund.csv'

MemoryProfiler.report{ Roo::Spreadsheet.open(file_name).tap{|x|(2..x.last_row).each{|i| x.row(i)}} }
puts Benchmark.measure{ Roo::Spreadsheet.open(file_name).tap{|x|(2..x.last_row).each{|i| x.row(i)}} }
```

Master
```
Total allocated: 39705265 bytes (561479 objects)
Total retained:  768 bytes (4 objects)

  0.300000   0.000000   0.300000 (  0.304877)
```

Modified:
```
Total allocated: 16952085 bytes (234487 objects)
Total retained:  768 bytes (4 objects)

  0.190000   0.000000   0.190000 (  0.181199)
```
chopraanmol1 added a commit to chopraanmol1/roo that referenced this issue Oct 5, 2018
### Summary

Fixes roo-rb#378 and roo-rb#374 (Introduced in roo-rb#368)

### Benchmark

```
file_name = 'test/files/Bibelbund.csv'

MemoryProfiler.report{ Roo::Spreadsheet.open(file_name).tap{|x|(2..x.last_row).each{|i| x.row(i)}} }
puts Benchmark.measure{ Roo::Spreadsheet.open(file_name).tap{|x|(2..x.last_row).each{|i| x.row(i)}} }
```

Master
```
Total allocated: 39705265 bytes (561479 objects)
Total retained:  768 bytes (4 objects)

  0.300000   0.000000   0.300000 (  0.304877)
```

Modified:
```
Total allocated: 16952085 bytes (234487 objects)
Total retained:  768 bytes (4 objects)

  0.190000   0.000000   0.190000 (  0.181199)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants