Topic
  • 2 replies
  • Latest Post - ‏2012-11-29T18:21:44Z by spssdeveloper
spssdeveloper
spssdeveloper
16 Posts

Pinned topic python script to export

‏2012-11-29T18:07:56Z |
Hi
I am exporting the spv file to an html format. I want to have the file name as the current date( eg. November292012). I am first trying to save it as some name. It gives me an error when I run the code below.

begin program.
import spss
import datetime
namelbl ="something"
spss.Submit("""
OUTPUT EXPORT /CONTENTS EXPORT=ALL LAYERS=PRINTSETTING MODELVIEWS=PRINTSETTING /HTML DOCUMENTFILE='c:\temp\%s.htm' NOTESCAPTIONS=YES STYLING=YES IMAGEFORMAT=JPG /JPG PERCENTSIZE=100 GRAYSCALE=NO
""" %(namelbl))
end program.

-Thanks
  • SystemAdmin
    SystemAdmin
    2077 Posts

    Re: python script to export

    ‏2012-11-29T18:17:07Z  
    \ characters in a Python string are used as escapes, so \t means a tab character. It's looking for a directory named c:<tab>emp, which is not what you want.

    There are three ways to fix this.
    1. Precede the literal with r, .e., r"""...
    That means a "raw" string, so \ is not treated as an escape character.
    2. Write the path using / instead. Both \ and / are honored by Statistics
    3. Double the backslash, e.g., c:\\temp...

    I always use both #1 and #2.

    HTH,
    Jon Peck
  • spssdeveloper
    spssdeveloper
    16 Posts

    Re: python script to export

    ‏2012-11-29T18:21:44Z  
    \ characters in a Python string are used as escapes, so \t means a tab character. It's looking for a directory named c:<tab>emp, which is not what you want.

    There are three ways to fix this.
    1. Precede the literal with r, .e., r"""...
    That means a "raw" string, so \ is not treated as an escape character.
    2. Write the path using / instead. Both \ and / are honored by Statistics
    3. Double the backslash, e.g., c:\\temp...

    I always use both #1 and #2.

    HTH,
    Jon Peck
    It worked!!!..Thanks..