Dear all, A piece of Python is refusing to work and I can't figure out what going wrong. The error I get is: Traceback (most recent call last): File "<string>", line 19, in <module> ValueError: unsupported format character '"' (0x22) at index 68 Now for my understanding: -The "BEGIN PROGRAM." line is line 1, right? So "line 19" should be 18 lines below that? Currently, there's no single double quote in that line! Line 19 is "compute fromsheet=%(sn).'''%locals())". I usually use triple double quotes here but I wanted to see whether replacing them with single ones could stop this error from popping up. -The "(0x22)" refers to ASCII character 22 (double quote, "), right? -What does "index 68" refer to here? -Why are straight double quotes printed back in my viewer as curly double quotes? Could that have anything to do with anything? This doesn't occur with single quotes. Thanks a lot for any advice! |
Hi Ruben, You start counting after the BEGIN PROGRAM. Dunno what's wrong without seeing the code, but I'm guessing you're using fancyquotes rather that 'simple' single or double quotes. Those quotes are not part of the ascii table. But it's just a guess ;-) Cheers!! Albert-Jan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
In reply to this post by Ruben Geert van den Berg
Hello,
The line is: "compute fromsheet=%(sn).'''%locals())". There are two double quotes and a triple inside which is strange. ValueError: unsupported format character '"' - it seems that here: %(sn). after the dot python looks for format instruction and finds ''' which is not proper format. Please check whether there is not something missing behind the dot and also look for triple quote matching the ''' inside the line. jindra > ------------ Původní zpráva ------------ > Od: Ruben van den Berg <[hidden email]> > Předmět: Python: ValueError: unsupported format character '"' (0x22) at > index 68 > Datum: 16.1.2012 12:37:30 > ---------------------------------------- > > Dear all, > A piece of Python is refusing to work and I can't figure out what going wrong. > The error I get is: > Traceback (most recent call last): File "<string>", line 19, in <module> > ValueError: unsupported format character '"' (0x22) at index 68 > Now for my understanding: > -The "BEGIN PROGRAM." line is line 1, right? So "line 19" should be 18 lines > below that? Currently, there's no single double quote in that line! Line 19 is > "compute fromsheet=%(sn).'''%locals())". I usually use triple double quotes here > but I wanted to see whether replacing them with single ones could stop this > error from popping up. > -The "(0x22)" refers to ASCII character 22 (double quote, "), right? > -What does "index 68" refer to here? > -Why are straight double quotes printed back in my viewer as curly double > quotes? Could that have anything to do with anything? This doesn't occur with > single quotes. > Thanks a lot for any advice! > > ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
In reply to this post by Ruben Geert van den Berg
The problem is that you forgot the "s"
in the format. The error refers to the character specifying the type
of conversion required.
You wrote compute fromsheet=%(sn).'''%locals())" but it should be compute fromsheet=%(sn)s.'''%locals())" This error message tends to occur a lot, and it could be clearer. (Not something that SPSS folks can fix). Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: Ruben van den Berg <[hidden email]> To: [hidden email] Date: 01/16/2012 03:53 AM Subject: [SPSSX-L] Python: ValueError: unsupported format character '"' (0x22) at index 68 Sent by: "SPSSX(r) Discussion" <[hidden email]> Dear all, A piece of Python is refusing to work and I can't figure out what going wrong. The error I get is: Traceback (most recent call last): File "<string>", line 19, in <module> ValueError: unsupported format character '"' (0x22) at index 68 Now for my understanding: -The "BEGIN PROGRAM." line is line 1, right? So "line 19" should be 18 lines below that? Currently, there's no single double quote in that line! Line 19 is "compute fromsheet=%(sn).'''%locals())". I usually use triple double quotes here but I wanted to see whether replacing them with single ones could stop this error from popping up. -The "(0x22)" refers to ASCII character 22 (double quote, "), right? -What does "index 68" refer to here? -Why are straight double quotes printed back in my viewer as curly double quotes? Could that have anything to do with anything? This doesn't occur with single quotes. Thanks a lot for any advice! |
Dear all,
Thanks for your help! Jon was right about the missing s. The entire code is now running smoothly! P.s. does anyone know what "at index 68" meant btw? Best, Ruben Date: Mon, 16 Jan 2012 06:43:42 -0700 From: [hidden email] Subject: Re: Python: ValueError: unsupported format character '"' (0x22) at index 68 To: [hidden email] The problem is that you forgot the "s" in the format. The error refers to the character specifying the type of conversion required. You wrote compute fromsheet=%(sn).'''%locals())" but it should be compute fromsheet=%(sn)s.'''%locals())" This error message tends to occur a lot, and it could be clearer. (Not something that SPSS folks can fix). Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: Ruben van den Berg <[hidden email]> To: [hidden email] Date: 01/16/2012 03:53 AM Subject: [SPSSX-L] Python: ValueError: unsupported format character '"' (0x22) at index 68 Sent by: "SPSSX(r) Discussion" <[hidden email]> Dear all, A piece of Python is refusing to work and I can't figure out what going wrong. The error I get is: Traceback (most recent call last): File "<string>", line 19, in <module> ValueError: unsupported format character '"' (0x22) at index 68 Now for my understanding: -The "BEGIN PROGRAM." line is line 1, right? So "line 19" should be 18 lines below that? Currently, there's no single double quote in that line! Line 19 is "compute fromsheet=%(sn).'''%locals())". I usually use triple double quotes here but I wanted to see whether replacing them with single ones could stop this error from popping up. -The "(0x22)" refers to ASCII character 22 (double quote, "), right? -What does "index 68" refer to here? -Why are straight double quotes printed back in my viewer as curly double quotes? Could that have anything to do with anything? This doesn't occur with single quotes. Thanks a lot for any advice! |
Free forum by Nabble | Edit this page |