Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
5 replies Latest Post - ‏2013-07-01T22:36:54Z by JonPeck
DanS.
DanS.
9 Posts
ACCEPTED ANSWER

Pinned topic Trailing spaces in output

‏2013-06-28T21:54:59Z |

Hi all,

 

I have a question about trailing spaces being added to my SPV output files.  I am using SPSS 19 and we are attempting to use python with the XML Workspace options.  However, one nagging issue is that the output is including a trailing space in the variable labels in the output (I have double and triple checked that the Variable Label itself does not have a trailing space).

 

Is there a setting in SPSS that I can be pointed to for addressing this? Or an easy bit of code that can be applied within spssaux.GetValuesFromXMLWorkspace that can be added to trim/strip the trailing spaces?  

 

Thanks,

 

Dan

  • JonPeck
    JonPeck
    325 Posts
    ACCEPTED ANSWER

    Re: Trailing spaces in output

    ‏2013-06-29T12:51:31Z  in response to DanS.

    I don't know where the extra space is coming from - perhaps you could post an example of the code involved, but you can apply the Python rstrip function to a label as in thelabel.restrip() to remove any trailing blanks.

    • DanS.
      DanS.
      9 Posts
      ACCEPTED ANSWER

      Re: Trailing spaces in output

      ‏2013-07-01T21:16:42Z  in response to JonPeck

      Thanks Jon for the rstrip code.  An example of the code is below:

      CTABLES
      /VLABELS VARIABLES=V1 V2 V3 Age DISPLAY=DEFAULT
      /TABLE (V1 + V2 + V3) [MEAN F40.1] BY Age 
      /CATEGORIES VARIABLES=Age ORDER=A KEY=VALUE EMPTY=EXCLUDE
      /TITLES TITLE='Scores'
      /TABLE (V1 + V2 + V3) [UCOUNT] BY Age 
      /CATEGORIES VARIABLES=Age ORDER=A KEY=VALUE EMPTY=EXCLUDE
      /TITLES TITLE='Counts'
      .
       
      -Dan
      Updated on 2013-07-01T21:17:54Z at 2013-07-01T21:17:54Z by DanS.
      • JonPeck
        JonPeck
        325 Posts
        ACCEPTED ANSWER

        Re: Trailing spaces in output

        ‏2013-07-01T21:48:28Z  in response to DanS.

        This doesn't tell me nearly enough.  Please show the relevant part of the Python code.  And where exactly does the extra space appear?  Are you in Unicode mode or code page mode?  getValuesFromXmlWorkspace returns the entries in the body of the table, which are presumably numeric, so they don't contain spaces.  Or are you saying that the table as seen in the Viewer has an extra space in the labels?

        • DanS.
          DanS.
          9 Posts
          ACCEPTED ANSWER

          Re: Trailing spaces in output

          ‏2013-07-01T22:01:49Z  in response to JonPeck

          Hi Jon,

           

          Sorry for the vague response.  The issue isn't a Python issue rather one with output.

           

          The issue I'm facing is that the tables in the output are adding a trailing space to my tables to my value labels.  Therefore, when I try to match a value label from the SAV file to the Output file, they no longer match. Further, this doesn't happen with all variables, and I am not sure why it happens to only some of them.

           

          I wasn't sure if there is a setting that I may need to click, or if I simply need to build my code to control for it.  It sounds like I may be best off simply adding the .rstrip() code to be safe and is fairly easy to implement.  

          Still trying to find my way around working with the XML Workspace itself.

           

          Thanks,

           

          -Dan

           

          • JonPeck
            JonPeck
            325 Posts
            ACCEPTED ANSWER

            Re: Trailing spaces in output

            ‏2013-07-01T22:36:54Z  in response to DanS.

            I'm still baffled about what you are doing.  Are you saving these tables with OMS as datasets?  Capturing them in some other way?  Looking at them in the p.t. editor?