Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'subject:Python': 0.05; 'properly.': 0.07; 'ioerror:': 0.09; 'open()': 0.09; 'skip:\\ 40': 0.09; 'subject:script': 0.09; 'to:addr:comp.lang.python': 0.09; 'whatever.': 0.09; 'cc:addr :python-list': 0.10; 'subject:not': 0.11; 'suggest': 0.11; 'properly': 0.15; 'csv': 0.16; 'jobs.': 0.16; 'sip': 0.16; 'subject:windows': 0.16; 'try/except': 0.16; 'wrote:': 0.17; 'input': 0.18; 'windows': 0.19; 'skip:" 30': 0.20; 'tells': 0.22; 'dependent': 0.23; 'cc:no real name:2**0': 0.24; 'cc:2**1': 0.24; 'pass': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; '(which': 0.26; 'skip:" 20': 0.26; '(most': 0.27; 'ago': 0.27; 'am,': 0.27; 'first,': 0.27; 'douglas': 0.29; 'maybe': 0.29; 'function': 0.30; 'error': 0.30; 'file': 0.32; "skip:' 20": 0.32; 'traceback': 0.33; 'problem': 0.33; 'received:google.com': 0.34; 'ahead': 0.35; 'from:addr:googlemail.com': 0.35; 'path': 0.35; 'open': 0.35; 'received:209.85': 0.35; 'method': 0.36; "i'll": 0.36; 'correctly': 0.37; 'resolve': 0.37; 'uses': 0.37; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'perform': 0.38; 'object': 0.38; 'some': 0.38; 'instead': 0.39; 'called': 0.39; 'your': 0.60; "you'll": 0.62; 'different': 0.63; 'lives': 0.71; '2013': 0.84; 'directory:': 0.84; 'imagine': 0.96 X-Received: by 10.49.98.42 with SMTP id ef10mr2325838qeb.15.1362452338801; Mon, 04 Mar 2013 18:58:58 -0800 (PST) Newsgroups: comp.lang.python Date: Mon, 4 Mar 2013 18:58:58 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=123.192.32.215; posting-account=5JdMBQoAAABHnS4mjpqEzxnmWtgiiVNw References: <5134f0d1$0$40360$4fafbaef@reader1.news.tin.it> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 123.192.32.215 MIME-Version: 1.0 Subject: Re: Python script not working on windows 7 but works fine on linux From: 88888 Dihedral To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Cc: io , python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 50 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362452346 news.xs4all.nl 6866 [2001:888:2000:d::a6]:33644 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40497 On Tuesday, March 5, 2013 3:20:28 AM UTC+8, ian douglas wrote: > On 03/04/2013 11:06 AM, io wrote: > > > esclusioni_file = open('/home/io/btc_trading/exclusions.txt','r') > > > > > > Windows error : > > > > > > Traceback (most recent call last): > > > File "C:\btc_trading\scripts > > > \import_json_2_csv_from_web_and_exclusions.py", line 10, in > > > f = open("/home/io/btc_trading/markets.csv","wb") > > > IOError: [Errno 2] No such file or directory: '/home/io/btc_trading/ > > > markets.csv' > > > > The error tells you everything you need to know: the file system has no > > path/file called "/home/io/btc_trading/markets.csv" > > > > I imagine your CSV file lives in a different location on your Windows 7 > > system (which also uses back-slashes '\' instead of forward-slashes '/', > > so you'll need to maybe do a try/except around the open() call to open a > > Windows path like open("c:\\users\\io\\Documents\\markets.csv") or > > whatever. OR you'll need to do some OS detection ahead of time to set > > the file path properly. Well, I'll suggest an old trick I did long time ago to resolve the platform dependent problem in python. Just write a generator as a buffered input method to work under some file of some OS correctly first, then you can pass the generator which is tested rigorously to act properly in the function or the object which will use the generator to sip up the data to perform jobs.