Windows Or Mac For Python

admin
Windows Or Mac For Python 6,2/10 4765 votes

I am new to python and I have a question about a piece of python code that creates a cleaned up output file from a model output file. This code was written for a Mac user, but now I want to run it in Windows. But it gives an error message. Could you help me in converting this code so I can use it in Windows? Import sys if len(sys.argv) > 1: fileName = sys.argv[1] else: print 'selected_um_b.out' #insert file name here sys.exit() f = open(fileName) counter = 0 fw = open(fileName+'.cleaned', 'w') for line in f: line = line.strip() counter = counter + 1 if counter. The program expects a filename on the command line when you execute it.

It appears you did not provide one, so the program exited (the sys.exit() call terminates the program). How are you trying to use it? If you just want to convert one file, put the file and the Python script into the same directory.

Supports Linux, Windows and Mac. And the Spyder IDE. Windows only, but more actively maintained and supports the latest Python 3 versions.

Replace lines 3 through 7 with filename = 'yourfilename.typ' (do not indent the line); it will read the file ('yourfilename.typ' in my example) and write an output file with 'cleaned' in the filename. The line values = line.split(' t') splits input lines (after the 4th line) into chunks that are separated by tabs. Nes emulator mac os x download. (That's what the backslash-t means - a tab).

Windows

The parts are put into the 'values' variable, which will be an array (actually a list, but you can think of it as an array). The likely problem is that some line contains fewer than 6 chunks; the values[4] and values[5] pick the 5th and 6th chunks from the array. (Numbering starts with zero, note one). Check your input file format.

– Feb 21 '12 at 22:02 •.