Python Forum
CVS file to EXCEL - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: CVS file to EXCEL (/thread-21977.html)

Pages: 1 2


RE: CVS file to EXCEL - snippsat - Oct-27-2019

Do not use single backslash \ as it used to escape characters that have special meaning,
such as newline \n or the error this case \N(named name in the Unicode).
>>> s = "F:\Carrier Bag F\NAV Padget\Padget.csv"
  File "<interactive input>", line 1
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 16-17: malformed \N character escape

>>> # Fix raw string(r)
>>> s = r"F:\Carrier Bag F\NAV Padget\Padget.csv"
>>> s
'F:\\Carrier Bag F\\NAV Padget\\Padget.csv'

>>> # Or \\ as you see over,other way / also work
>>> s = "F:/Carrier Bag F/NAV Padget/Padget.csv"
>>> s
'F:/Carrier Bag F/NAV Padget/Padget.csv'



RE: CVS file to EXCEL - DavidTheGrockle - Oct-28-2019

OK. Worked. Thank you.