how do i fix this invalid arguement error

Terry Reedy tjreedy at udel.edu
Sat Nov 26 14:18:32 EST 2016


On 11/26/2016 12:55 PM, Dennis Lee Bieber wrote:
> On Sat, 26 Nov 2016 08:12:46 -0800 (PST), junkone1 at gmail.com declaimed the
> following:
>
>> import csv
>> with open('\\192.168.0.1\fe18cb0618cabd41\ninjatrader$EURUSDTestRun 2016-11-25-11-11.csv','r') as f:
>>    reader=csv.reader(f)
>>    for row in reader:
>>        print(row)
>>
>>
>>  File "C:/Users/Suresh/PycharmProjects/untitled/test.py", line 2, in <module>
>>    with open('\\192.168.0.1\fe18cb0618cabd41\ninjatrader$EURUSDTestRun 2016-11-25-11-11.csv','r') as f:
>> OSError: [Errno 22] Invalid argument: '\\192.168.0.1\x0ce18cb0618cabd41\ninjatrader$EURUSDTestRun 2016-11-25-11-11.csv'
>
>
> 	First suggestion... Make it a RAW string. What you have has an embedded
> new-line character making it:
> \\192.168.0.1\fe18cb0618cabd41
> injatrader$EURUSDTestRun 2016-11-25-11-11.csv

Or use forward slashes:
with open('/192.168.0.1/fe18cb0618cabd41/ninjatrader$EURUSDTestRun 
2016-11-25-11-11.csv','r') as f:

> 	Second... does Python open() accept web addresses? What is at
> 192.168.0.1 that you don't have some more sensible path to it? 192.168.0.1
> is a private local network address. You are on a Windows machine so if the
> file is available on a local network node you can probably mount that node
> (Computer/Map Network Drive) and access the file as something like
> Z:/ninjatrader...
>


-- 
Terry Jan Reedy




More information about the Python-list mailing list