On Sun, 27 Nov 2016 03:12 am, junko...@gmail.com wrote:

> import csv
> with open('\\192.168.0.1\fe18cb0618cabd41\ninjatrader$EURUSDTestRun
> 2016-11-25-11-11.csv','r') as f:

\f inserts a FORMFEED character, ASCII code 12. \n inserts a LINEFEED
character, or newline, ASCII code 10. I believe that on Windows, both are
illegal in file names. And \\ inserts a single backslash.

You have three solutions:

(1) Use forward slashes, which Windows accepts as well:

'//192.168.0.1/fe18cb0618cabd41/ninjatrader$EURUSDTestRun
2016-11-25-11-11.csv'


(2) Use a "raw string" to disable most (but not all) backslash escapes:

r'\\192.168.0.1\fe18cb0618cabd41\ninjatrader$EURUSDTestRun
2016-11-25-11-11.csv'


The problem with raw strings is that you cannot end a string with a
backslash, so you cannot write:

# this gives a syntax error
r'C:\My Documents\directory\'


(3) Or escape all your backslashes with more backslashes:

'\\\\192.168.0.1\\fe18cb0618cabd41\\ninjatrader$EURUSDTestRun
2016-11-25-11-11.csv'




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to