How do I use a back slash as a delimiter, python wont recognize it.
ofile = open('MapServicesInfo.csv', "w")
writer = csv.writer(ofile, delimiter = '\', quotechar='"', quoting=csv.QUOTE_ALL)
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?
This is an example of a row I need to write to csv file by delimiting the slash.
Write each section within the slashes to separate rows .
I guess I need to know how to make it not recognize as a escape character ?
... \Sewer\ControlValve
Here is the process
>>> a = "Sewer\ControlValve" >>> b = a.split("\\") >>> b ['Sewer', 'ControlValve'] >>> c = ("{}\n"*len(b)).format(*b) >>> c 'Sewer\nControlValve\n' >>> print(c) Sewer ControlValve
Now that can be simplified of course
Interesting I just added .split ("\\)
writer.writerow([fullpath.split("\\")])
I get the following which correctly splits it at the slashes and yields commas.
['Sewer', 'ControlValve']
So, I only need to write to different rows where it is has a comma.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.