<?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: End-of-line (EOL) Problem in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391045#M30898</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I ran into the same problem when using python to add hyperlinks. As hyperlinks contain "\" characters it sometimes happened that a "\n" was in the hyperlink. I solved it by passing in the hyperlink as a raw string instead of a normal string:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;hyperlink = "c:\somehyperlink\name_of_file"
arcpy.CalculateField_management(TableToEdit, "HYPERLINK_FIELD", r"r'" + hyperlink + r"'", "PYTHON")&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The above code embeds a newline (\n) in the string: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; print "c:\somehyperlink\name_of_file"
c:\somehyperlink
ame_of_file&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think this may work better:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt; print 'r"{0}"'.format(r"c:\somehyperlink\name_of_file")
r"c:\somehyperlink\name_of_file"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;hyperlink = r"c:\somehyperlink\name_of_file"
arcpy.CalculateField_management(TableToEdit, "HYPERLINK_FIELD", '{0}"'.format(hyperlink), "PYTHON")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I thought I'd add one more thing to this post: how to specify newlines in the Calculate Field tool in ModelBuilder. The interactive tool dialog parser converts "\n" to real newlines in the code box, which doesn't work, so the workaround is to to use chr(10). I've used this as a quick and dirty way to have model builder print a message:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression: &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;msg()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
def msg():
&amp;nbsp; # text = "\n\nThis is\na message to you.\n"&amp;nbsp; # does not work
&amp;nbsp; text = "{0}{0}This is{0}a message to you.{0}".format(chr(10))
&amp;nbsp; return text&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 17:55:42 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2021-12-11T17:55:42Z</dc:date>
    <item>
      <title>End-of-line (EOL) Problem</title>
      <link>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391036#M30889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Came across a weird EOL Error with Arcpy's CalculateField_management() function today and I was wondering if anyone out there could point me towards a work around?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I previewed one of my tables in Catalog and at first glance the offending cells seemed fine.&amp;nbsp; However, when I copy/pasted one over to a text file a lot more text became visible. My current theory is that the Enter key is being hit when my customers edit cells in MS Excel (my typical source data) and invisible newline characters are being carried into my geodatabase tables.&amp;nbsp; Tricky thing is I can't see them in Excel or Arc, so I'm not sure how to strip or replace the backslashes via Python.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any advice would be much appreciated,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- Nick&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Feb 2012 18:22:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391036#M30889</guid>
      <dc:creator>NickJacob</dc:creator>
      <dc:date>2012-02-15T18:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: End-of-line (EOL) Problem</title>
      <link>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391037#M30890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try dumping the table to a text file, if you think there is stuff going on in there you cannot see.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is an 're' module in python that handles regular expressions. That is the tool set you want for weeding out pesky newlines ('\n').&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It may be easier to weed them in the table or in the text dump (which could then be re-imported to a table).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Feb 2012 18:53:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391037#M30890</guid>
      <dc:creator>markdenil</dc:creator>
      <dc:date>2012-02-15T18:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: End-of-line (EOL) Problem</title>
      <link>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391038#M30891</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Try dumping the table to a text file, if you think there is stuff going on in there you cannot see.&lt;BR /&gt;&lt;BR /&gt;There is an 're' module in python that handles regular expressions. That is the tool set you want for weeding out pesky newlines ('\n').&lt;BR /&gt;&lt;BR /&gt;It may be easier to weed them in the table or in the text dump (which could then be re-imported to a table).&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the quick response!&amp;nbsp; I copied a cell over to Notepad++ and it turns out each line is proceeded with a carriage return and line feed (CR LF).&amp;nbsp; Ordinarily, I would just clean-up data by hand, but in this case I need a script to filter this sort of thing.&amp;nbsp; Have you ever seen this done via field calculator by chance?&amp;nbsp; I've been experimenting with regular expressions, but no luck so far.&amp;nbsp; I keep getting "EOL while scanning string literal" related errors.&amp;nbsp; One of my many attempts below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
#ESRI Codeblock
codeblock="""def trimNewline(val):
&amp;nbsp;&amp;nbsp;&amp;nbsp; import re
&amp;nbsp;&amp;nbsp;&amp;nbsp; newVal = re.sub('(?m)[\r\n]',"",val)
&amp;nbsp;&amp;nbsp;&amp;nbsp; return newVal"""

#Expression parameter
expression = "trimNewline(str(!FIELD!))

# CalculateField_management(in_table,field,expression,{expression_type},{code_block})
arcpy.CalculateField_management(mytable,"FIELDNAME",expression,"PYTHON",codeblock)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:55:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391038#M30891</guid>
      <dc:creator>NickJacob</dc:creator>
      <dc:date>2021-12-11T17:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: End-of-line (EOL) Problem</title>
      <link>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391039#M30892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There's a nice python string method that trims whitespace around strings:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; x
'\r\nhere is my real text\n'
&amp;gt;&amp;gt;&amp;gt; x.strip()
'here is my real text'&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So one approach you could use would be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.CalculateField_management(mytable,"FIELDNAME","!FIELDNAME!.strip()","PYTHON")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One could also use VBScript:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.CalculateField_management(mytable,"FIELDNAME","Trim([FIELDNAME]")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:55:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391039#M30892</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T17:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: End-of-line (EOL) Problem</title>
      <link>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391040#M30893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;-------&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Update&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-------&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just a quick update to anyone that may come across this post down the road (and big thank you to mdenil and curtvprice).&amp;nbsp; The short-term conclusion I've come to is that it's not possible to feed hidden newline characters ('\n') into the Field Calculator.&amp;nbsp; Also, because carriage returns and newlines are special, some functions can't access them like I had anticipated, such as strip().&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Workaround was to convert the problem strings to hexadecimal and swap out values with an Update Cursor. See example below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
rows = arcpy.UpdateCursor(fc)
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(row.NAME) &amp;gt;= 255:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hexString = str(row.NAME).encode("hex")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if "0a" in hexString: # "0a" is hex equivalent of '\n'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hexString = hexString.replace("0a","")
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.NAME = hexString.decode("hex")
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Definitely not ideal, but seems reliable so far.&amp;nbsp; Another interesting thing is that my problem carriage returns magically disappeared somewhere earlier in my script, when converting an Excel worksheet to an in-memory feature class.&amp;nbsp; This might suggest another arcpy function stripped them out, but not sure which one.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:55:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391040#M30893</guid>
      <dc:creator>NickJacob</dc:creator>
      <dc:date>2021-12-11T17:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: End-of-line (EOL) Problem</title>
      <link>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391041#M30894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is a useful thread.&amp;nbsp; I've run in to related problems in how to find and correct them (VB vs Python). When performing Python field calculations on fields containing \n, \x, etc, I get the same errors as Nick described--but I don't get them when using VB (because \n et al aren't special in VB?). So a few points:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) I didn't even realize string fields could support carriage returns! Apparently this is new as of 9.2? For example, my address string field can contain:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;568 N Courier Ct&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and I can type more here&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and here if I use "ctrl+enter"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;or if the incoming table&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;had \n or \r for line breaks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;... but when I visually inspect the cell, all I see is "568 N Courier Ct" since it's on the first line. It is not visually apprent without starting an edit session, highlighting text, and dragging and/or arrowing. This is a real hazard when importing from text files or Excel; this could really drive somebody nuts when geocoding imported addresses.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Besides \n, I've also run in to problems with \x in the fields as well. I guess any of the reserved characters would be problematic. ArcGIS SQL is a little helpful for spotting these, in that&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SELECT * FROM street_features WHERE&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"street" LIKE '%&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;finds all instances of carriage returns in the "street" field ... but I have no idea how to write a similar query to find instances of \x, \b, etc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3) Nick's hexidecimal conversion seems to work for \n but, again, how can we apply it to other special characters? Or is it just easier to use VB instead of Python for field calculations?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jul 2012 21:12:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391041#M30894</guid>
      <dc:creator>Waan</dc:creator>
      <dc:date>2012-07-27T21:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: End-of-line (EOL) Problem</title>
      <link>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391042#M30895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Cool idea using SQL to search for carriage returns.&amp;nbsp; Later on, I came to the conclusion that I shouldn't bother stripping out the carriage returns, or any of the other random problems with the data for that matter.&amp;nbsp; At some point I needed to shift the responsibility of data maintenance over to the end user of whatever model or script I was writing.&amp;nbsp; So, in the end I think I included some exception handling to specifically watch for them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As for the never ending programming language of preference debate, does it really matter?&amp;nbsp; Who honestly writes more than a handful of scripts or models per year anyways?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Jul 2012 20:54:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391042#M30895</guid>
      <dc:creator>NickJacob</dc:creator>
      <dc:date>2012-07-28T20:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: End-of-line (EOL) Problem</title>
      <link>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391043#M30896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Or is it just easier to use VB instead of Python for field calculations?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I believe (and I think many would agree) that Python has far superior string manipulation capabilities.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here are some pretty good Python methods for stripping non printables:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://stackoverflow.com/questions/92438/stripping-non-printable-characters-from-a-string-in-python"&gt;http://stackoverflow.com/questions/92438/stripping-non-printable-characters-from-a-string-in-python&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://stackoverflow.com/questions/1276764/stripping-everything-but-alphanumeric-chars-from-a-string-in-python"&gt;http://stackoverflow.com/questions/1276764/stripping-everything-but-alphanumeric-chars-from-a-string-in-python&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jul 2012 04:22:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391043#M30896</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2012-07-30T04:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: End-of-line (EOL) Problem</title>
      <link>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391044#M30897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;3) Nick's hexidecimal conversion seems to work for \n but, again, how can we apply it to other special characters? Or is it just easier to use VB instead of Python for field calculations?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I ran into the same problem when using python to add hyperlinks. As hyperlinks contain "\" characters it sometimes happened that a "\n" was in the hyperlink. I solved it by passing in the hyperlink as a raw string instead of a normal string:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;hyperlink = "c:\somehyperlink\name_of_file"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CalculateField_management(TableToEdit, "HYPERLINK_FIELD", r"r'" + hyperlink + r"'", "PYTHON")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2012 12:43:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391044#M30897</guid>
      <dc:creator>Janvan_Linge</dc:creator>
      <dc:date>2012-11-07T12:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: End-of-line (EOL) Problem</title>
      <link>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391045#M30898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I ran into the same problem when using python to add hyperlinks. As hyperlinks contain "\" characters it sometimes happened that a "\n" was in the hyperlink. I solved it by passing in the hyperlink as a raw string instead of a normal string:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;hyperlink = "c:\somehyperlink\name_of_file"
arcpy.CalculateField_management(TableToEdit, "HYPERLINK_FIELD", r"r'" + hyperlink + r"'", "PYTHON")&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The above code embeds a newline (\n) in the string: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; print "c:\somehyperlink\name_of_file"
c:\somehyperlink
ame_of_file&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think this may work better:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt; print 'r"{0}"'.format(r"c:\somehyperlink\name_of_file")
r"c:\somehyperlink\name_of_file"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;hyperlink = r"c:\somehyperlink\name_of_file"
arcpy.CalculateField_management(TableToEdit, "HYPERLINK_FIELD", '{0}"'.format(hyperlink), "PYTHON")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I thought I'd add one more thing to this post: how to specify newlines in the Calculate Field tool in ModelBuilder. The interactive tool dialog parser converts "\n" to real newlines in the code box, which doesn't work, so the workaround is to to use chr(10). I've used this as a quick and dirty way to have model builder print a message:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression: &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;msg()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
def msg():
&amp;nbsp; # text = "\n\nThis is\na message to you.\n"&amp;nbsp; # does not work
&amp;nbsp; text = "{0}{0}This is{0}a message to you.{0}".format(chr(10))
&amp;nbsp; return text&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:55:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391045#M30898</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T17:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: End-of-line (EOL) Problem</title>
      <link>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391046#M30899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I do not believe that this problem has been sufficiently adressed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using the Field Calculator box, with text containing a CR-LF (Characters 10-13), I have tested all of the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;Using a replace ('\r\n', '')&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Using strip&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Using filter&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Using a comprehension that decompiles and checks individual characters&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;SPAN&gt;Even using a Codeblock, these tactics did not seem to work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, if I go from the console and set up something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rows = arcpy.UpdateCursor(fc)
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if '\r\n' in row.TextString:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue('TextString', row.TextString.replace('\r\n', ' '))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)
&amp;nbsp;&amp;nbsp;&amp;nbsp; del row
del rows&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;It works exactly as one would expect. But I would love to know more about why this doesn't seem to work from the Field Calculator window.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:55:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391046#M30899</guid>
      <dc:creator>MarcNakleh</dc:creator>
      <dc:date>2021-12-11T17:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: End-of-line (EOL) Problem</title>
      <link>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391047#M30900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yeah, still not working.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Apr 2013 16:49:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391047#M30900</guid>
      <dc:creator>IB1</dc:creator>
      <dc:date>2013-04-10T16:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: End-of-line (EOL) Problem</title>
      <link>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391048#M30901</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; &lt;BR /&gt;However, if I go from the console and set up something like:&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
rows = arcpy.UpdateCursor(fc)
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if '\r\n' in row.TextString:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue('TextString', row.TextString.replace('\r\n', ' '))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)
del row, rows
&lt;/PRE&gt;&lt;BR /&gt;It works exactly as one would expect. But I would love to know more about why this doesn't seem to work from the Field Calculator window.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is that you cannot use Python escape codes like "\r" in the Field Calculator code block or the Calculate Value code block. I'm assuming this has something to do with the parsing of python arguments into string representation in the arcpy/gp messaging framework.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you need to access escape characters, use &lt;/SPAN&gt;&lt;A href="http://docs.python.org/3/library/functions.html#chr" rel="nofollow noopener noreferrer" target="_blank"&gt;the chr() function&lt;/A&gt;&lt;SPAN&gt; instead. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This will probably work fine:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
rows = arcpy.UpdateCursor(fc)
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; newline = chr(13) + chr(10)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if newline in row.TextString:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue('TextString', row.TextString.replace(newline, ' '))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)
del row, rows
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:55:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391048#M30901</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T17:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: End-of-line (EOL) Problem</title>
      <link>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391049#M30902</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The problem is that you cannot use Python escape codes like "\r" in the Field Calculator code block or the Calculate Value code block. I'm assuming this has something to do with the parsing of python arguments into string representation in the arcpy/gp messaging framework.&lt;BR /&gt;&lt;BR /&gt;If you need to access escape characters, use &lt;A href="http://docs.python.org/3/library/functions.html#chr" rel="nofollow noopener noreferrer" target="_blank"&gt;the chr() function&lt;/A&gt; instead. &lt;BR /&gt;&lt;BR /&gt;This will probably work fine:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rows = arcpy.UpdateCursor(fc)
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; newline = chr(13) + chr(10)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if newline in row.TextString:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue('TextString', row.TextString.replace(newline, ' '))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)
&amp;nbsp;&amp;nbsp;&amp;nbsp; del row
del rows&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Curtis, I'll give that a shot.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:55:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391049#M30902</guid>
      <dc:creator>IanBroad2</dc:creator>
      <dc:date>2021-12-11T17:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: End-of-line (EOL) Problem</title>
      <link>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391050#M30903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Curtis,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think I was too vague: the cursor example I provided &lt;/SPAN&gt;&lt;STRONG&gt;works fine&lt;/STRONG&gt;&lt;SPAN&gt;. However, NOTHING I have tried in the Field Calculator box worked. Even if I replace references of '\r\n' to (chr13) + chr(10), it still doesn't work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One of the responses on &lt;/SPAN&gt;&lt;A href="http://gis.stackexchange.com/questions/44460/how-to-remove-return-newline-n-character-from-field-using-python-and-field-ca"&gt;GIS StackExchange describing the exact same problem&lt;/A&gt;&lt;SPAN&gt; recommends the same thing as you, and those who tried it seemed to have just as little luck as I did.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I set up a quick test just to make sure that I was isolating the issue:&lt;/SPAN&gt;&lt;BR /&gt;&lt;OL&gt;&lt;BR /&gt;&lt;LI&gt;In a new shapefile, I add 2 text fields (TEXTFIELD, NEWTEXTF)&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;I create a single feature&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;I type the following text in Notepad: "This is a&lt;SPAN style="font-style:italic;"&gt;[ENTER]&lt;/SPAN&gt;test" (where &lt;SPAN style="font-style:italic;"&gt;[ENTER]&lt;/SPAN&gt; represents pressing the Enter button)&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;I copy-paste this text (which is on two lines) into the feature's TEXTFIELD value&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;I then run the following in FieldCalculator: NEWTEXTF = !TEXTFIELD!.upper()&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;&lt;/LI&gt;&lt;BR /&gt;&lt;/OL&gt;&lt;BR /&gt;&lt;SPAN&gt;This generates the following error message:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;Executing: CalculateField test NEWTEXTF !TEXTFIELD!.upper() PYTHON_9.3 #&lt;BR /&gt;Start Time: Thu Jul 18 12:35:16 2013&lt;BR /&gt;ERROR 000539: Error running expression: "This is a&lt;BR /&gt;test".upper() &amp;lt;type 'exceptions.SyntaxError'&amp;gt;: EOL while scanning string literal (&amp;lt;string&amp;gt;, line 1)&lt;BR /&gt;Failed to execute (CalculateField).&lt;BR /&gt;Failed at Thu Jul 18 12:35:16 2013 (Elapsed Time: 0,00 seconds)&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any attempts to replace the newlines, using either either escape sequences or chr() calls, result in the same error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It looks as if the CalculateField is passing along the newlines unescaped, which breaks the interpreter.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, a couple of questions come to mind:&lt;/SPAN&gt;&lt;BR /&gt;&lt;OL&gt;&lt;BR /&gt;&lt;LI&gt;Do you get the same behaviour as me for the basic case of !TEXTFIELD!.upper()?&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;If yes, does this mean that ALL CalculateField calls that use the Python interpreter need to have their input sanitized to remove newlines? Or that we should just switch to Cursors in all cases to avoid any errors or difficulties?&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Could you paste the actual working code you used to get the example working properly?&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;&lt;/LI&gt;&lt;BR /&gt;&lt;/OL&gt;&lt;BR /&gt;&lt;SPAN&gt;If you'd prefer, we can correspond directly by e-mail too, so I can send you the samples I have.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks so much!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jul 2013 16:05:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391050#M30903</guid>
      <dc:creator>MarcNakleh</dc:creator>
      <dc:date>2013-07-18T16:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: End-of-line (EOL) Problem</title>
      <link>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391051#M30904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Dang it!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why does the field calculator for Python reject standard strings with \t , \n, etc. characters? The only one it seems to accept is \r.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;e.g. f.write(!textfield1!+', '+!textfield2!+'\r') works&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but f.write(!textfield1!+',\t'+!textfield2!+'\t') doesn't work&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This bug severely limits the possibilities for writing output from a table to a file or an email.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What is the point of castrating Python's string operators?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Aug 2013 13:37:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391051#M30904</guid>
      <dc:creator>KarstenSedmera</dc:creator>
      <dc:date>2013-08-05T13:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: End-of-line (EOL) Problem</title>
      <link>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391052#M30905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Could you paste the actual working code you used to get the example working properly?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import os
import arcpy

tbl = arcpy.CreateScratchName("","","table","in_memory")
arcpy.CreateTable_management("in_memory",os.path.basename(tbl))
arcpy.AddField_management(tbl,"TESTFIELD","TEXT")
Rows = arcpy.InsertCursor(tbl)
Row = Rows.newRow()
Rows.insertRow(Row)
del Row, Rows
arcpy.CalculateField_management(tbl,"TESTFIELD","chr(10) + chr(13)","PYTHON_9.3")
print arcpy.GetMessages()
Rows = arcpy.SearchCursor(tbl)
Row = Rows.next()
print "Field value: ",repr(Row.TESTFIELD)
del Row, Rows
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Results:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Executing: CalculateField in_memory\xx0 TESTFIELD "chr(10) + chr(13)" PYTHON_9.3 #
Start Time: Mon Aug 05 10:49:33 2013
Succeeded at Mon Aug 05 10:49:33 2013 (Elapsed Time: 0.00 seconds)
Field value:&amp;nbsp; u'\n\r'
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also this worked fine for me:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]26465[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think the problem you're running into is using the value of the field !TESTFIELD! if the field contains newlines - the tool will substitute in the value of the field into the expression - the geoprocessing messaging and Python interpreter can't deal with this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think the method you found is a good approach, that is, using Python with cursors (using the Calculate Value tool if in ModelBuilder) instead of using Calculate Field.&amp;nbsp; I don't see another way around this, which is a design issue with the way Calculate Field accesses field values, and its connection with the geoprocessing message environment in how things are passed to Python. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Seems to me this is a good enhancement request for Calculate Field, i.e. have non printables converted to escape codes as part of the !FIELDNAME! -&amp;gt; value substitution process.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:55:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391052#M30905</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T17:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: End-of-line (EOL) Problem</title>
      <link>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391053#M30906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Why does the field calculator for Python reject standard strings with \t , \n, etc. characters? &lt;BR /&gt;&lt;BR /&gt;What is the point of castrating Python's string operators?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is a limitation of the ArcGIS geoprocessing tool setup, which has to pass all tool parameters in string representation. The expression and code block are Calculate Field tool parameters. (String reps are easily used to pass tool parameters across the web, XML, etc.) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The fix is to use the chr() function instead of escape codes in your expression or Calculate Field code block.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Aug 2013 16:21:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391053#M30906</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2013-08-05T16:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: End-of-line (EOL) Problem</title>
      <link>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391054#M30907</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is the solution that worked for me, though I removed the len(row.NAME) &amp;gt;= 255 requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the working example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

&lt;SPAN style="font-size: 12.0pt; font-family: 'Courier New'; color: black;"&gt;rows = arcpy.UpdateCursor("Assets\Welds")&lt;/SPAN&gt;


&lt;SPAN style="font-size: 12.0pt; font-family: 'Courier New'; color: #004da8;"&gt;for&lt;/SPAN&gt;&lt;SPAN style="font-size: 12.0pt; font-family: 'Courier New'; color: black;"&gt; row &lt;/SPAN&gt;&lt;SPAN style="font-size: 12.0pt; font-family: 'Courier New'; color: #004da8;"&gt;in&lt;/SPAN&gt;&lt;SPAN style="font-size: 12.0pt; font-family: 'Courier New'; color: black;"&gt; rows:&lt;/SPAN&gt;


&lt;SPAN style="font-size: 12.0pt; font-family: 'Courier New'; color: black;"&gt; hexString = str(row.REMARKS).encode("hex")&lt;/SPAN&gt;


&lt;SPAN style="font-size: 12.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 12.0pt; font-family: 'Courier New'; color: #004da8;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 12.0pt; font-family: 'Courier New'; color: black;"&gt; "0a" &lt;/SPAN&gt;&lt;SPAN style="font-size: 12.0pt; font-family: 'Courier New'; color: #004da8;"&gt;in&lt;/SPAN&gt;&lt;SPAN style="font-size: 12.0pt; font-family: 'Courier New'; color: black;"&gt; hexString:&lt;/SPAN&gt;


&lt;SPAN style="font-size: 12.0pt; font-family: 'Courier New'; color: black;"&gt; hexString = hexString.replace("0a","")&lt;/SPAN&gt;


&lt;SPAN style="font-size: 12.0pt; font-family: 'Courier New'; color: black;"&gt; row.REMARKS = hexString.decode("hex")&lt;/SPAN&gt;


&lt;SPAN style="font-size: 12.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)&lt;/SPAN&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Replace "Assets\Welds" with the appropriate fc name and replace row.REMARKS with row.(insert field name here)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may or may not need to run:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import string



&lt;/PRE&gt;&lt;P&gt;I just wanted to make this idiotproof because I struggled for a bit (I copied and pasted your example expecting it to work).&amp;nbsp; I'm still somewhat new to (and still learning) Python so I'm sure I'm not the only one who will forget to change the appropriate variables to their ArcGIS data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:55:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391054#M30907</guid>
      <dc:creator>ZacharyOrdo__GISP</dc:creator>
      <dc:date>2021-12-11T17:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: End-of-line (EOL) Problem</title>
      <link>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391055#M30908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This method seems a little dangerous as I can envision where the string "0a" could occur in your hex string by accident, for example the two byte hex "b0 ac" represented this way would be an invalid match.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a function implementation of your approach, not using hex codes. You could paste this function into the ArcMap python window and use it there. Note I'm using chr(10) and chr(13) for "\n" and "\r" so this function can also be used inside the Calculate Value tool in modelbuilder... as the usual use of "\n" breaks the geoprocessing messaging string representation in the code...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm also using arcpy.da.UpdateCursor because it is very fast compared to the 10.0 flavor.... and the "with" construct helps you out by closing the cursor even if the code fails -- avoiding the possibility of a nasty hanging file lock!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14073609798327898" jivemacro_uid="_14073609798327898"&gt;
&lt;P&gt;import arcpy&lt;/P&gt;
&lt;P&gt;def strip_newlines(tbl, field, eolchar=""):&lt;/P&gt;
&lt;P&gt;&amp;nbsp; with arcpy.da.UpdateCursor(tbl, [field]) as rows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[0] = row[0].replace(chr(10), eolchar).replace(chr(13), eolchar) &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)&amp;nbsp; &lt;/P&gt;


&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 21:37:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/end-of-line-eol-problem/m-p/391055#M30908</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2014-08-06T21:37:19Z</dc:date>
    </item>
  </channel>
</rss>

