roo-rb / roo

Roo provides an interface to spreadsheets of several sorts.
MIT License
2.79k stars 501 forks source link

key not found: :txt #422

Open andreas-it-dev opened 6 years ago

andreas-it-dev commented 6 years ago

Hello,

i am trying to import a tab delimited txt file but get the error

key not found: :txt

any idea where the issue might be?

thank you, Andreas

tgturner commented 6 years ago

Roo currently only suppourts 'ods', 'xlsx', 'xlsm', and 'csv' file types. I do believe that we could handle the error better. Please feel free to open a PR that gives a more informative error when you try to parse a spreadsheet with a file extension that Roo does not know about!

chopraanmol1 commented 6 years ago

@awunder we do support tab delimited file as csv. e.g.

# Load a tab-delimited csv
csv = Roo::CSV.new("mytsv.tsv", csv_options: {col_sep: "\t"})

Can you provide sample code and sample file which can be used to reproduce this issue. Also posting error backtrace here will help a lot.

tgturner commented 6 years ago

Interesting, I was assuming that he was using Roo::Spreadsheet.open('path-to-tab-deliminated-file.txt')

Which would have lead here: https://github.com/roo-rb/roo/blob/master/lib/roo/spreadsheet.rb#L11

However, I see when that happens you get this error: ArgumentError (Can't detect the type of xyz.txt - please use the :extension option to declare its type.). A reproduction example would be helpful because I'm no longer sure what path was being followed.