parseexcel and email fields

Discussion in 'Ruby' started by Jason Fox, Oct 2, 2006.

  1. Jason Fox

    Jason Fox Guest

    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, Oct 2, 2006
    #1
    1. Advertising

  2. Jason Fox

    Hannes Wyss Guest

    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 <> 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, Oct 2, 2006
    #2
    1. Advertising

  3. Jason Fox

    Jason Fox Guest

    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/.
     
    Jason Fox, Oct 2, 2006
    #3
  4. Jason Fox

    Hannes Wyss Guest

    > 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
     
    Hannes Wyss, Oct 2, 2006
    #4
  5. Jason Fox

    Jason Guest

    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
     
    Jason, Oct 13, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nigel Wilkinson

    problems with parseexcel module

    Nigel Wilkinson, Dec 2, 2003, in forum: Ruby
    Replies:
    0
    Views:
    98
    Nigel Wilkinson
    Dec 2, 2003
  2. Hannes Wyss

    [ANN] Spreadsheet::ParseExcel

    Hannes Wyss, Feb 7, 2006, in forum: Ruby
    Replies:
    4
    Views:
    212
    Anu Sebastian
    Aug 4, 2009
  3. Hannes Wyss

    [ANN] ParseExcel 0.4.0 released

    Hannes Wyss, Feb 16, 2006, in forum: Ruby
    Replies:
    0
    Views:
    90
    Hannes Wyss
    Feb 16, 2006
  4. Replies:
    2
    Views:
    116
  5. roberto0

    UTF-8 and Spreadsheet::ParseExcel

    roberto0, Aug 17, 2005, in forum: Perl Misc
    Replies:
    1
    Views:
    284
    roberto0
    Aug 17, 2005
Loading...

Share This Page