<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Bug in Model Builder Code Block when dealing with \n in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/bug-in-model-builder-code-block-when-dealing-with/m-p/1154220#M52847</link>
    <description>&lt;P&gt;I don't think the bug with "\n" in the code block is the problem. You're actually passing a multi line string literal into the &lt;FONT face="courier new,courier"&gt;Result&lt;/FONT&gt; function&lt;/P&gt;&lt;P&gt;Expression:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Result(r"%Value (3)%")&lt;/LI-CODE&gt;&lt;P&gt;Is getting converted by ArcGIS to:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Result(r"Your text file
contents with
lots of 
new
lines...")&lt;/LI-CODE&gt;&lt;P&gt;Which is a syntax error.&lt;/P&gt;&lt;P&gt;You can use triple quotes to handle multi line string literals (did you see my other &lt;A href="https://community.esri.com/t5/arcgis-pro-questions/multi-line-text-entry-in-model-builder-parameter/m-p/1153650/highlight/true#M52768" target="_self"&gt;post&lt;/A&gt;?)&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Result(r"""%Value (3)%""")&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 16 Mar 2022 12:43:56 GMT</pubDate>
    <dc:creator>Luke_Pinner</dc:creator>
    <dc:date>2022-03-16T12:43:56Z</dc:date>
    <item>
      <title>Bug in Model Builder Code Block when dealing with \n</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/bug-in-model-builder-code-block-when-dealing-with/m-p/1153669#M52773</link>
      <description>&lt;P&gt;So I've got a problem I'm trying to solve using a python expression in a "Calculate Value" step in Model Builder. In short, I'm trying to replace new line characters (\n) with "" to change a multi-line input text string (from a text file) to a single line of text (which will play nice with Field Calculator). However, it seems that I can't find a way to make the characters "\n" stay in my expression. As soon as I click out of the Code Block, the characters disappear and the following line of script moves down onto a new line. I've tried the 2 below combinations with the same result (3rd image). In a standalone python script, this doesn't happen. Would you consider this a bug?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LindsayRaabe_FPCWA_0-1647324377776.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/36329iA60FAB21F9DE5C15/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LindsayRaabe_FPCWA_0-1647324377776.png" alt="LindsayRaabe_FPCWA_0-1647324377776.png" /&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LindsayRaabe_FPCWA_2-1647324397273.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/36331i16BBACF58F584BFF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LindsayRaabe_FPCWA_2-1647324397273.png" alt="LindsayRaabe_FPCWA_2-1647324397273.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LindsayRaabe_FPCWA_1-1647324386651.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/36330iF865E962012C10FF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LindsayRaabe_FPCWA_1-1647324386651.png" alt="LindsayRaabe_FPCWA_1-1647324386651.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 06:07:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/bug-in-model-builder-code-block-when-dealing-with/m-p/1153669#M52773</guid>
      <dc:creator>LindsayRaabe_FPCWA</dc:creator>
      <dc:date>2022-03-15T06:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: Bug in Model Builder Code Block when dealing with \n</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/bug-in-model-builder-code-block-when-dealing-with/m-p/1153695#M52777</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;chr(10)&lt;/FONT&gt; is equivalent to &lt;FONT face="courier new,courier"&gt;"\n"&lt;/FONT&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;print(f"X{chr(10)}X")
X
X&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or the &lt;FONT face="courier new,courier"&gt;os.linesep&lt;/FONT&gt; workaround noted in the bug&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/3515"&gt;@DuncanHornby&lt;/a&gt;&amp;nbsp; submitted. 2019, that's pretty poor...&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 21:58:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/bug-in-model-builder-code-block-when-dealing-with/m-p/1153695#M52777</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2022-03-15T21:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Bug in Model Builder Code Block when dealing with \n</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/bug-in-model-builder-code-block-when-dealing-with/m-p/1153906#M52802</link>
      <description>&lt;P&gt;I logged this as &lt;A href="https://support.esri.com/en/bugs/nimbus/QlVHLTAwMDEyMDE1Mg==" target="_self"&gt;bug&lt;/A&gt; in 2019, its disappointing that they still have not fixed it in 3 years! I remember the support response offered up a ridiculous work around and clearly were not understanding the impact that this bug would have, i.e. as you are discovering making it impossible to write code in a Calculate Value tool in model builder if you use standard python \n notation.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 17:03:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/bug-in-model-builder-code-block-when-dealing-with/m-p/1153906#M52802</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2022-03-15T17:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: Bug in Model Builder Code Block when dealing with \n</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/bug-in-model-builder-code-block-when-dealing-with/m-p/1154131#M52833</link>
      <description>&lt;P&gt;I just tried my code block with the line you suggested.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LindsayRaabe_FPCWA_0-1647392250437.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/36445i1FD089B4E9EADA59/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LindsayRaabe_FPCWA_0-1647392250437.png" alt="LindsayRaabe_FPCWA_0-1647392250437.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LindsayRaabe_FPCWA_1-1647392327637.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/36446iAC2F2F654C055795/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LindsayRaabe_FPCWA_1-1647392327637.png" alt="LindsayRaabe_FPCWA_1-1647392327637.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LindsayRaabe_FPCWA_3-1647392387326.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/36448i154F55906AB213B1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LindsayRaabe_FPCWA_3-1647392387326.png" alt="LindsayRaabe_FPCWA_3-1647392387326.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Assuming I've written it correctly, it still doesn't seem to work (I have tried chr(10), "chr(10)", {chr(10)}&amp;nbsp; and "{chr(10}" as well without any luck). All come up with the below error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LindsayRaabe_FPCWA_2-1647392350791.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/36447i48420A458DB4FE84/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LindsayRaabe_FPCWA_2-1647392350791.png" alt="LindsayRaabe_FPCWA_2-1647392350791.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 01:00:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/bug-in-model-builder-code-block-when-dealing-with/m-p/1154131#M52833</guid>
      <dc:creator>LindsayRaabe_FPCWA</dc:creator>
      <dc:date>2022-03-16T01:00:48Z</dc:date>
    </item>
    <item>
      <title>Re: Bug in Model Builder Code Block when dealing with \n</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/bug-in-model-builder-code-block-when-dealing-with/m-p/1154220#M52847</link>
      <description>&lt;P&gt;I don't think the bug with "\n" in the code block is the problem. You're actually passing a multi line string literal into the &lt;FONT face="courier new,courier"&gt;Result&lt;/FONT&gt; function&lt;/P&gt;&lt;P&gt;Expression:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Result(r"%Value (3)%")&lt;/LI-CODE&gt;&lt;P&gt;Is getting converted by ArcGIS to:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Result(r"Your text file
contents with
lots of 
new
lines...")&lt;/LI-CODE&gt;&lt;P&gt;Which is a syntax error.&lt;/P&gt;&lt;P&gt;You can use triple quotes to handle multi line string literals (did you see my other &lt;A href="https://community.esri.com/t5/arcgis-pro-questions/multi-line-text-entry-in-model-builder-parameter/m-p/1153650/highlight/true#M52768" target="_self"&gt;post&lt;/A&gt;?)&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Result(r"""%Value (3)%""")&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 16 Mar 2022 12:43:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/bug-in-model-builder-code-block-when-dealing-with/m-p/1154220#M52847</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2022-03-16T12:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: Bug in Model Builder Code Block when dealing with \n</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/bug-in-model-builder-code-block-when-dealing-with/m-p/1154226#M52848</link>
      <description>&lt;P&gt;The work around was to pass in the new line character as part of the function call, so I have this model:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="DuncanHornby_0-1647435385492.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/36470i3AFBDDE5F4B518C5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DuncanHornby_0-1647435385492.png" alt="DuncanHornby_0-1647435385492.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The Calculate Value tool is this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="DuncanHornby_1-1647435459710.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/36471iAFDFEC6DEB9AFB24/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DuncanHornby_1-1647435459710.png" alt="DuncanHornby_1-1647435459710.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 12:57:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/bug-in-model-builder-code-block-when-dealing-with/m-p/1154226#M52848</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2022-03-16T12:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: Bug in Model Builder Code Block when dealing with \n</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/bug-in-model-builder-code-block-when-dealing-with/m-p/1155111#M52972</link>
      <description>&lt;P&gt;You're right - I forgot to include the triple quotes (yes, I had seen the other post). I added them in and it worked - sort of. I gave me a result, but one that still contains the new line characters. I believe the triple quotes has solved the input value issue, but still hasn't resulted in a query that removes the new line values from the output value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LindsayRaabe_FPCWA_0-1647569735994.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/36682i77B0D3CEF51C32AF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LindsayRaabe_FPCWA_0-1647569735994.png" alt="LindsayRaabe_FPCWA_0-1647569735994.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LindsayRaabe_FPCWA_4-1647570089417.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/36686i5FC9FA9F037679DE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LindsayRaabe_FPCWA_4-1647570089417.png" alt="LindsayRaabe_FPCWA_4-1647570089417.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried out Duncan's suggestion of putting the new line characters into the function call, and TaDa! Managed to get out a single line of text!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LindsayRaabe_FPCWA_7-1647570411138.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/36689i6684916B65D4B95B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LindsayRaabe_FPCWA_7-1647570411138.png" alt="LindsayRaabe_FPCWA_7-1647570411138.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LindsayRaabe_FPCWA_6-1647570404210.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/36688i4B97B13B369772B7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LindsayRaabe_FPCWA_6-1647570404210.png" alt="LindsayRaabe_FPCWA_6-1647570404210.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is good news because now I can do away with the separate python script tool that I was using the achieve the same result! Thanks all for your input and patience!&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2022 02:29:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/bug-in-model-builder-code-block-when-dealing-with/m-p/1155111#M52972</guid>
      <dc:creator>LindsayRaabe_FPCWA</dc:creator>
      <dc:date>2022-03-18T02:29:10Z</dc:date>
    </item>
  </channel>
</rss>

