[Tutor] csv module not raising exception properly

Kent Johnson kent37 at tds.net
Thu Apr 7 21:28:24 CEST 2005


David Rock wrote:
> I am trying to catch an exception from the csv module but it doesn't
> seem to be generating a proper exception because I don't seem to be able
> to catch it. Here is what I am doing:
> 
> 
> for inputline in fileinput.input(args):
> 	try:
> 		input = csv.reader([inputline], escapechar='\\')
> 	except:
> 		print "ERROR", inputline
> 
> 
> This is the traceback:
> Traceback (most recent call last):
>   File "/usr/openv/local/bin/bpdbreport_test.py", line 539, in ?
>     for line in input:
> _csv.Error: newline inside string

I'm suspicious of this - the traceback doesn't match the code you show. Is your program called 
bpdbreport_test.py? What is happening at line 539 of bpdbreport_test.py?

Kent



More information about the Tutor mailing list