<?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: Python csv.writer delimiter with \ ? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306628#M23830</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is the process&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = "Sewer\ControlValve"
&amp;gt;&amp;gt;&amp;gt; b = a.split("\\")
&amp;gt;&amp;gt;&amp;gt; b
['Sewer', 'ControlValve']
&amp;gt;&amp;gt;&amp;gt; c = ("{}\n"*len(b)).format(*b)
&amp;gt;&amp;gt;&amp;gt; c
'Sewer\nControlValve\n'
&amp;gt;&amp;gt;&amp;gt; print(c)
Sewer
ControlValve&lt;/PRE&gt;&lt;P&gt;Now that can be simplified of course&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 14:40:48 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2021-12-11T14:40:48Z</dc:date>
    <item>
      <title>Python csv.writer delimiter with \ ?</title>
      <link>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306625#M23827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How do I use a back slash as a delimiter, python wont recognize it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffe4ff;"&gt;ofile&lt;/SPAN&gt;&amp;nbsp; = &lt;SPAN style="color: #000080;"&gt;open&lt;/SPAN&gt;(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;'MapServicesInfo.csv'&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"w"&lt;/SPAN&gt;)&lt;/P&gt;&lt;P&gt;writer = csv.writer(ofile, &lt;SPAN style="color: #660099;"&gt;delimiter &lt;/SPAN&gt;= &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'\'&lt;/SPAN&gt;, &lt;SPAN style="color: #660099;"&gt;quotechar&lt;/SPAN&gt;=&lt;SPAN style="color: #008000; font-weight: bold;"&gt;'"'&lt;/SPAN&gt;, &lt;SPAN style="color: #660099;"&gt;quoting&lt;/SPAN&gt;=csv.QUOTE_ALL)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jul 2016 19:39:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306625#M23827</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2016-07-21T19:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: Python csv.writer delimiter with \ ?</title>
      <link>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306626#M23828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In python a backslash is an escape character. I don't think you'll be able to use for a csv. Have you tried using 2 \\ or a forward / slash?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jul 2016 20:30:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306626#M23828</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2016-07-21T20:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: Python csv.writer delimiter with \ ?</title>
      <link>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306627#M23829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is an example of a row I need to write to csv file by delimiting the slash.&lt;/P&gt;&lt;P&gt;Write each section within the slashes to separate rows .&lt;/P&gt;&lt;P&gt;I guess I need to know how to make it not recognize as a escape character ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... \Sewer\ControlValve&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jul 2016 20:37:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306627#M23829</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2016-07-21T20:37:10Z</dc:date>
    </item>
    <item>
      <title>Re: Python csv.writer delimiter with \ ?</title>
      <link>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306628#M23830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is the process&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = "Sewer\ControlValve"
&amp;gt;&amp;gt;&amp;gt; b = a.split("\\")
&amp;gt;&amp;gt;&amp;gt; b
['Sewer', 'ControlValve']
&amp;gt;&amp;gt;&amp;gt; c = ("{}\n"*len(b)).format(*b)
&amp;gt;&amp;gt;&amp;gt; c
'Sewer\nControlValve\n'
&amp;gt;&amp;gt;&amp;gt; print(c)
Sewer
ControlValve&lt;/PRE&gt;&lt;P&gt;Now that can be simplified of course&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:40:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306628#M23830</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T14:40:48Z</dc:date>
    </item>
    <item>
      <title>Re: Python csv.writer delimiter with \ ?</title>
      <link>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306629#M23831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Interesting I just added .split ("\\)&lt;/P&gt;&lt;P&gt;writer.writerow([fullpath.split(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"\\"&lt;/SPAN&gt;)])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get the following which correctly splits it at the slashes and yields&amp;nbsp; commas.&lt;/P&gt;&lt;P&gt;['Sewer', 'ControlValve']&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, I only need to write to different rows where it is has a comma.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jul 2016 21:13:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306629#M23831</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2016-07-21T21:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: Python csv.writer delimiter with \ ?</title>
      <link>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306630#M23832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I handled that in my example&lt;/P&gt;&lt;P&gt;see line 5&lt;/P&gt;&lt;P&gt;if you have to do this, all it does is determine the length of the list (hence the len(b)) and multiplies the format designator {} the correct number of times, then adds a newline&lt;/P&gt;&lt;P&gt;hence.... line 5&lt;/P&gt;&lt;P&gt;this is equivalent to&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use my c syntax&lt;/P&gt;&lt;P&gt;for i in c:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.writerow(i)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and you are done&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jul 2016 21:28:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306630#M23832</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-07-21T21:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: Python csv.writer delimiter with \ ?</title>
      <link>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306631#M23833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the help&lt;/P&gt;&lt;P&gt;I put the following and results in vertical rather than horizontal and each letter is written to a different cell.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;b = fullpath.split(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"\\"&lt;/SPAN&gt;)&lt;/P&gt;&lt;P&gt;c = (&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"{}\n" &lt;/SPAN&gt;* &lt;SPAN style="color: #000080;"&gt;len&lt;/SPAN&gt;(b)).format(*b)&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;for &lt;/SPAN&gt;i &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;c:&lt;/P&gt;&lt;P&gt;&amp;nbsp; writer.&lt;SPAN style="background-color: #e4e4ff;"&gt;writerow (i )&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jul 2016 22:19:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306631#M23833</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2016-07-21T22:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Python csv.writer delimiter with \ ?</title>
      <link>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306632#M23834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;simpler still... use b if you have to write one row at a time&lt;/P&gt;&lt;P&gt;for i in b: print(i)&lt;/P&gt;&lt;P&gt;... &lt;/P&gt;&lt;P&gt;Sewer&lt;/P&gt;&lt;P&gt;ControlValve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jul 2016 22:26:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306632#M23834</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-07-21T22:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: Python csv.writer delimiter with \ ?</title>
      <link>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306633#M23835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;b = fullpath.split(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;'\\'&lt;/SPAN&gt;)&lt;/P&gt;&lt;P&gt;c = (&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"{}\n" &lt;/SPAN&gt;* &lt;SPAN style="color: #000080;"&gt;len&lt;/SPAN&gt;(b)).format(*b)&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;for &lt;/SPAN&gt;i &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;b:&lt;/P&gt;&lt;P&gt;&amp;nbsp; writer.writerow(i)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is one step closer. Yet writing into single cells and vertically.&lt;/P&gt;&lt;P&gt;S\"E"\"W"...&lt;/P&gt;&lt;P&gt;C\"O"\"N"...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jul 2016 22:37:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306633#M23835</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2016-07-21T22:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: Python csv.writer delimiter with \ ?</title>
      <link>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306634#M23836</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;grief... it obviously don't write the newline&lt;/P&gt;&lt;P&gt;so try to add it&lt;/P&gt;&lt;P&gt;writer.writerow( i + "\n" )&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jul 2016 22:39:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306634#M23836</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-07-21T22:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: Python csv.writer delimiter with \ ?</title>
      <link>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306635#M23837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;there is something wrong with the example you gave me, since it shouldn't be splitting things out letter by letter.&amp;nbsp; it should just split on "\\"&lt;/P&gt;&lt;P&gt;You had better do a test on that to see if it works with your inputs&lt;/P&gt;&lt;P&gt;I would convert fullpath to a string first, then post that example since there is something amiss in my examples and your inputs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jul 2016 22:42:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-csv-writer-delimiter-with/m-p/306635#M23837</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-07-21T22:42:23Z</dc:date>
    </item>
  </channel>
</rss>

