locked
Empty fields in a CSV file RRS feed

  • Question

  • I'm seeing this in the CSV file created by BizTalk:

    1234.Meter 1,  ,  ,  ,MSP,  ,  ,0,1,1,0 
    The user asked me if we could change to this:
    1234,Meter 1,,,,MSP,,,0,1,1,0
    The requirements were that these were unused fields.  In my map, I have a String-Concatenate functoid with a value of an empty string.

    Here's some snippets from the generated XSLT:

      <xsl:variable name="var:v32" select="userCSharp:StringConcat(" ")" /> 
    
     <APUser20_NotUsed>
       <xsl:value-of select="$var:v32" /> 
     </APUser20_NotUsed>
     <AQUser21_NotUsed>
       <xsl:value-of select="$var:v32" /> 
     </AQUser21_NotUsed>
    

    The fields are defined as follows:   Date Type=xs:string, Default Value (not specified), Justification=Left, MinLen with Pad Char (no value specified), there is no wrap character.

    I'm not sure why I'm getting two space between each comma when the field is empty.  The XSLT seems to be changing my empty-string to one in my functoid to one space.  I have pressed delete and backspace, and there is absolutely nothing in the field.  I can change that to a Script functoid or something else that returns "".  But where does the second space come from? 

    Thanks,

    Neal


    Thursday, November 29, 2012 7:49 PM

Answers

  • I removed the String-Concat functoid that was initializing the fields, and everything looks good now. I'm one of those people that likes to explicitly declare things, rather than letting defaults do their magic. 

    Thanks for all advice,
    Neal

    • Marked as answer by Neal Walters Friday, November 30, 2012 3:41 PM
    Friday, November 30, 2012 3:41 PM

All replies

  • Hi Neal,

    Change the value in StringConcat to "" (empty string) instead of " " (space).


    Thanks, mm2709

    Thursday, November 29, 2012 8:37 PM
  • From the looks of the userCharp:StringConcat(" "), it looks like it contains a space.  Are there other mappings done in your map or was this map to generate empty fields?

    If it was to generate empty nodes, you can use a setting in the flat file schema to do this for you (see below):


    David Downing... If this answers your question, please Mark as the Answer. If this post is helpful, please vote as helpful.

    Thursday, November 29, 2012 8:41 PM
  • Looks like an odd bug with the mapper/XSLT.  I created a brand new BizTalk project, created a dummy schema, and the String Concat functoids generates proper XSLT:

     <xsl:variable name="var:v1" select="userCSharp:StringConcat("")" /> 
    However, in my real-world map, I can type in some value other than space, then delete it, and the XSLT still shows a blank between the quotes.

    Further, maybe it wasn't obvious in my original question, but there are actually TWO spaces between the commas in the output file.

    Neal


    • Edited by Neal Walters Thursday, November 29, 2012 10:45 PM
    Thursday, November 29, 2012 9:49 PM
  • Double check a Pad character. Maybe there is a space.

    Leonid Ganeline [BizTalk MVP] BizTalkien: Advanced Questions

    Thursday, November 29, 2012 11:18 PM
    Moderator
  • Hi,

    Since the fields are unused fields, you don't need to map these to anything, not even to empty string concatenate. The xslt then will look like :

    <!-- <xsl:variable name="var:v32" select="userCSharp:StringConcat(" ")" /> --> Commented

    <APUser20_NotUsed>
       <!--
    <xsl:value-of select="$var:v32" /> --> Commented
    </APUser20_NotUsed>
    <AQUser21_NotUsed>
     <!--  
    <xsl:value-of select="$var:v32" /> --> Commented
    </AQUser21_NotUsed>

    Commented the actual mapping fields. You just need to create the output nodes without mappings and the rest will be taken care by BizTalk piepline for converting to CSV file.

    Try this & please let me know if it generates the file in your required format.

    Thanks,
    Sumit

    Friday, November 30, 2012 6:00 AM
  • I removed the String-Concat functoid that was initializing the fields, and everything looks good now. I'm one of those people that likes to explicitly declare things, rather than letting defaults do their magic. 

    Thanks for all advice,
    Neal

    • Marked as answer by Neal Walters Friday, November 30, 2012 3:41 PM
    Friday, November 30, 2012 3:41 PM