osx - Python can't recognize file in Mac OS X -
i've got following small program runs fine on windows 7:
import csv filename = raw_input('enter input file name: ') outfile = raw_input('enter output file name: ') open(filename) f, open(outfile,'w') f2: writer = csv.writer(f2, delimiter = '\n') line in f: x, y = line.split() writer.writerow([y]*int(x)) however, running same code on mac, when give input.txt input file, "error 2: input.txt, no such file or directory" error.
so far we've confirmed we're running in same working directory input file. we've tried entering complete path (with , without quotation marks) instead of file name. we've tried explicitly specifying encoding - utf8 - though i'm not sure should necessary. keep getting same "no such file or directory" error. again, runs fine under windows. ideas?
update: ok, invisible leading whitespace in file name turned out problem. runs fine once rid of (although it's mystery why osx puts there in first place...)
Comments
Post a Comment