[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

parseexcel and email fields

Jason Fox

10/1/2006 11:12:00 PM



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-....

8 Answers

Paul Lutus

10/2/2006 5:27:00 AM

0

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.ara...

Hannes Wyss

10/2/2006 9:02:00 AM

0

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.ara...
>
>

Jason Fox

10/2/2006 4:44:00 PM

0

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-....

Hannes Wyss

10/2/2006 7:13:00 PM

0

> 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 Fox

10/12/2006 11:04:00 PM

0

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

re-Pete

7/2/2012 3:34:00 PM

0

Moder@tor wrote:

Let's remind folks here what you believe in, fascist:

"No one is forbidding the media of freedom of speech, just asking them
to surpress information for one day while the voting process happens."

"Only taking the temporary ban a step further."

"Unconstitutional to forbid election day coverage? How so?"

"I'm all for a media blackout on election data and stories on election
day..."



Barack Hussein Bohica

7/4/2012 4:32:00 AM

0

On Mon, 02 Jul 2012 10:21:20 +0200, "Moder@tor" <Moder@tor.com> wrote:

>On Mon, 02 Jul 2012 00:58:12 -0700, 254 murdered in Obama's 'organized
>communities' <CharlieFoxtrot@whitehouse.gov> wrote:
>
>>On Sun, 01 Jul 2012 10:18:34 +0200, "Moder@tor" <Moder@tor.com> wrote:
>>
>>>http://www.boston.com/news/local/massachusetts/articles/2012/07/01/court_approval_of_health_law_sets_national_stage_for_the_cost_limits_that_massachusetts_i...
>>>
>>>What the challenges are, who is doing the compromising in the battle for lower
>>>medical costs, etc. It's pretty clear that RomneyCare has led to serious
>>>dialogue on how to reduce health care spending. The whole state is interested in
>>>working to evolve the plan to make it more effective. I see the same for the
>>>future of ObamaCare. No one plan can be the end all, fix all, for the future and
>>>beyond. But we needed a start. Like it or not, it is just that. And.....it is
>>>legal! Romney has always been of the mindset that it is cheaper to insure
>>>everyone than to pay the high cost of the uninsured. I agree wholeheartedly. How
>>>we insure everyone is the question. Both Obama and Romney have instituted
>>>programs as starting points. It is ultimately up to everyone to make sure they
>>>work correctly.
>>
>>Obama tells us we shouldn't vote for Romney because of what he did in
>>one state. Why the hell would we then want to vote for Obama who is
>>doing it to all 58 states?
>
>It makes me laugh.

Looking in a mirror again?

>>Obama needs a new hobby. Russian Roulette sounds like a winner.
>
>Why don't you try it first and report back to us, ok?

I already know how it works. Obama playing it would have far more
productive effect on the nation.

Moder@tor

7/5/2012 7:45:00 PM

0

On Tue, 03 Jul 2012 21:31:52 -0700, 254 murdered in Obama's 'organized
communities' <CharlieFoxtrot@whitehouse.gov> wrote:

>On Mon, 02 Jul 2012 10:21:20 +0200, "Moder@tor" <Moder@tor.com> wrote:
>
>>On Mon, 02 Jul 2012 00:58:12 -0700, 254 murdered in Obama's 'organized
>>communities' <CharlieFoxtrot@whitehouse.gov> wrote:
>>
>>>On Sun, 01 Jul 2012 10:18:34 +0200, "Moder@tor" <Moder@tor.com> wrote:
>>>
>>>>http://www.boston.com/news/local/massachusetts/articles/2012/07/01/court_approval_of_health_law_sets_national_stage_for_the_cost_limits_that_massachusetts_i...
>>>>
>>>>What the challenges are, who is doing the compromising in the battle for lower
>>>>medical costs, etc. It's pretty clear that RomneyCare has led to serious
>>>>dialogue on how to reduce health care spending. The whole state is interested in
>>>>working to evolve the plan to make it more effective. I see the same for the
>>>>future of ObamaCare. No one plan can be the end all, fix all, for the future and
>>>>beyond. But we needed a start. Like it or not, it is just that. And.....it is
>>>>legal! Romney has always been of the mindset that it is cheaper to insure
>>>>everyone than to pay the high cost of the uninsured. I agree wholeheartedly. How
>>>>we insure everyone is the question. Both Obama and Romney have instituted
>>>>programs as starting points. It is ultimately up to everyone to make sure they
>>>>work correctly.
>>>
>>>Obama tells us we shouldn't vote for Romney because of what he did in
>>>one state. Why the hell would we then want to vote for Obama who is
>>>doing it to all 58 states?
>>
>>It makes me laugh.
>
>Looking in a mirror again?
>
>>>Obama needs a new hobby. Russian Roulette sounds like a winner.
>>
>>Why don't you try it first and report back to us, ok?
>
>I already know how it works. Obama playing it would have far more
>productive effect on the nation.

Where is Smith29 when you need him? He'd say 'You need an ice water enema.'