Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
handle a special foramt error when importing csv
Raimon Fs
12/9/2007 8:03:00 PM
hello,
I have to import lots of csv files, and sometimes, there's one with the
csv that is not quite good formatted, and Ruby send a:
CSV::IllegalFormatError in DadeController#import_file_data_ajax
CSV::IllegalFormatError
I'm trying to handle the error with
begin
# Exceptions raised by this code will
# be caught by the following rescue clause
... some code ...
rescue Exception
$stderr.print "IO failed: " + $!
... some code ...
raise
but the error/exception never raises ...
I tried with SystemCAllError, StandardError, Exception, ...
The error happens in:
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/csv.rb:639:in
`get_row'
because the file hasn't the expected formatted, it's not a csv file, but
the file has an extension of csv, that's why I want to catch those
exceptions ...
thanks,
regards
raimon
--
Posted via
http://www.ruby-...
.
2 Answers
Michael Guterl
12/9/2007 9:56:00 PM
0
Note: parts of this message were removed by the gateway to make it a legal Usenet post.
Hi,
On Dec 9, 2007 3:03 PM, Raimon Fs <coder@montx.com> wrote:
> hello,
>
> I have to import lots of csv files, and sometimes, there's one with the
> .csv that is not quite good formatted, and Ruby send a:
>
> CSV::IllegalFormatError in DadeController#import_file_data_ajax
> CSV::IllegalFormatError
>
> I'm trying to handle the error with
>
> begin
> # Exceptions raised by this code will
> # be caught by the following rescue clause
>
> ... some code ...
>
>
> rescue Exception
try this,
rescue CSV::IllegalFormatError
> $stderr.print "IO failed: " + $!
>
> ... some code ...
>
> raise
>
>
> but the error/exception never raises ...
>
> I tried with SystemCAllError, StandardError, Exception, ...
>
> The error happens in:
>
> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/csv.rb:639:in
> `get_row'
>
> because the file hasn't the expected formatted, it's not a csv file, but
> the file has an extension of csv, that's why I want to catch those
> exceptions ...
>
> thanks,
>
> regards
>
>
> raimon
> --
> Posted via
http://www.ruby-...
.
>
HTH,
Michael Guterl
Raimon Fs
12/9/2007 10:47:00 PM
0
Michael Guterl wrote:
> Hi,
>
> On Dec 9, 2007 3:03 PM, Raimon Fs <coder@montx.com> wrote:
>
>> begin
>> # Exceptions raised by this code will
>> # be caught by the following rescue clause
>>
>> ... some code ...
>>
>>
>> rescue Exception
>
>
> try this,
> rescue CSV::IllegalFormatError
thanks, I'll try that ...
I wasn't aware that I could simply catch those errors, beacuse I would
like a more general error, because I don't know in advance how many
errors I'm going to find ...
regards,
rai
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
handle a special foramt error when importing csv
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password