[Tutor] Trying a csv error
Tim Johnson
tim at johnsons-web.com
Fri Feb 10 23:06:46 CET 2006
Hello:
I'm using the csv module, and resources are imported as in
import csv
My exception trapping uses
etype, value, tb = sys.exc_info()
and I'm getting the following
value = "newline inside string"
type = "_csv.Error"
I would like to proceed with the assumption for now that this
error should not abort processing.
The relevant code snippet is as follows:
while(1):
try:
reader.next() ## csv object method
except StopIteration:
break
I'd like to do the following
while(1):
try:
reader.next() ## csv object method
except cvs._csv.Error: ## or something like this
print "bad csv record, skipping ...."
continue
except StopIteration:
break
The problem is that python does not recognize the
error objects and gives me:
"'module' object has no attribute '_csv'".
Any ideas on how to trap this error?
Thanks
tim
--
Tim Johnson <tim at johnsons-web.com>
http://www.alaska-internet-solutions.com
More information about the Tutor
mailing list