Parseexcel and email fields

I am having a problem reading in a spreadsheet that contains email
addresses in one of the columns. I get a "cannot convert nil into
String" error when I try to parse the spreadsheet (see below).

Has anyone else had success with using parseexcel with spreadsheets that
contain email addresses? Any help would be much appreciated.

Regards,
Jason

Here is the stack trace:

can't convert nil into String - (TypeError)
/usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:249:in `<<'
/usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:249:in
`get_big_data'
/usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:138:in
`get_data'
/usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:290:in
`get_nth_pps'
/usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:281:in
`get_nth_pps'
/usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:199:in
`initialize'
/usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:355:in
`get_header'
/usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:110:in
`initialize'
/usr/local/lib/ruby/site_ruby/1.8/parseexcel/parser.rb:172:in `parse'
/usr/local/lib/ruby/site_ruby/1.8/parseexcel/parseexcel.rb:10:in `parse'
...

···

--
Posted via http://www.ruby-forum.com/.

Jason Fox wrote:

I am having a problem reading in a spreadsheet that contains email
addresses in one of the columns. I get a "cannot convert nil into
String" error when I try to parse the spreadsheet (see below).

Has anyone else had success with using parseexcel with spreadsheets that
contain email addresses? Any help would be much appreciated.

Regards,
Jason

Here is the stack trace:

can't convert nil into String - (TypeError)
/usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:249:in `<<'
/usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:249:in
`get_big_data'
/usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:138:in
`get_data'
/usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:290:in
`get_nth_pps'
/usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:281:in
`get_nth_pps'
/usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:199:in
`initialize'
/usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:355:in
`get_header'
/usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:110:in
`initialize'
/usr/local/lib/ruby/site_ruby/1.8/parseexcel/parser.rb:172:in `parse'
/usr/local/lib/ruby/site_ruby/1.8/parseexcel/parseexcel.rb:10:in `parse'
..

I am willing to bet the problem lies somewhere in the code ... the code you
didn't post.

···

--
Paul Lutus
http://www.arachnoid.com

Jason

if you (can) send me the xls in question off list, I'll be happy to investigate.

cheers,
Hannes

···

On 10/2/06, Paul Lutus <nospam@nosite.zzz> wrote:

Jason Fox wrote:

>
> I am having a problem reading in a spreadsheet that contains email
> addresses in one of the columns. I get a "cannot convert nil into
> String" error when I try to parse the spreadsheet (see below).
>
> Has anyone else had success with using parseexcel with spreadsheets that
> contain email addresses? Any help would be much appreciated.
>
> Regards,
> Jason
>
> Here is the stack trace:
>
> can't convert nil into String - (TypeError)
> /usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:249:in `<<'
> /usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:249:in
> `get_big_data'
> /usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:138:in
> `get_data'
> /usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:290:in
> `get_nth_pps'
> /usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:281:in
> `get_nth_pps'
> /usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:199:in
> `initialize'
> /usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:355:in
> `get_header'
> /usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:110:in
> `initialize'
> /usr/local/lib/ruby/site_ruby/1.8/parseexcel/parser.rb:172:in `parse'
> /usr/local/lib/ruby/site_ruby/1.8/parseexcel/parseexcel.rb:10:in `parse'
> ..
>

I am willing to bet the problem lies somewhere in the code ... the code you
didn't post.

--
Paul Lutus
http://www.arachnoid.com

Hannes Wyss wrote:

Jason

if you (can) send me the xls in question off list, I'll be happy to
investigate.

cheers,
Hannes

Hannes I have emailed you this message along with the files that I am
using and the complete stack trace. I'm posting this follow-up here for
the benefit of the forum. Thanks again!

···

---

I have narrowed down the cause of my issue a bit further.

I am using parseexcel in a backgroundrb worker to parse a spreadsheet
that was uploaded through a web form and then stored in the database.
When I use parseexcel in the console to parse the original file, it
works fine. However, when I parse the temp file that I create from the
database it throws this exception. The files are of identical size, but
a call to diff reports that they do indeed differ. Excel, however,
opens the temp file without issue.

Regards,
Jason

--
Posted via http://www.ruby-forum.com/\.

Hannes I have emailed you this message along with the files that I am
using and the complete stack trace.

... so far nothing has arrived on my side of the atlantic.

When I use parseexcel in the console to parse the original file, it
works fine. However, when I parse the temp file that I create from the
database it throws this exception. The files are of identical size, but
a call to diff reports that they do indeed differ. Excel, however,
opens the temp file without issue.

Ah, well then it _would_ be good to see your code.
Do you maybe need to rewind your file before passing it to ParseExcel?

all the best
Hannes

The rewind worked! -- I don't quite understand why though.

After writing out the temporary file I am passing the _name_ of the
file to the ParseExcel parse method, so why is the file pointer at the
end of the file? Doesn't ParseExcel just open up a new IO stream using
the passed in filename?

    # create the temporary file from the data stored in the database
(RoR model)
    temp_file = Tempfile.new('project_file')
    temp_file.write(project_file.file_data)

    # parse the spreadsheet with parseexcel
    workbook = Spreadsheet::ParseExcel.parse(temp_file.path)

Thanks for your help!

P.S. - Is there a way to have parseexcel work directly off of an IO
stream or do you _always_ have to have a file on-hand?

Regards,
Jason

Hannes Wyss wrote:

···

> Hannes I have emailed you this message along with the files that I am
> using and the complete stack trace.
.. so far nothing has arrived on my side of the atlantic.

> When I use parseexcel in the console to parse the original file, it
> works fine. However, when I parse the temp file that I create from the
> database it throws this exception. The files are of identical size, but
> a call to diff reports that they do indeed differ. Excel, however,
> opens the temp file without issue.
Ah, well then it _would_ be good to see your code.
Do you maybe need to rewind your file before passing it to ParseExcel?

all the best
Hannes