Question

I successfully created an .exe using py2exe with a simple test script I found on a tutorials website. The script I am using, however, does not seem to work. My code uses the csv module and dict reader with two .csv inputs.

I run the python setup.py p2exe command, and I get a flash of a command prompt, but that disappears before I can read anything on it. And once it disappears, I do not have the correct .csv file output that I would get if I just ran the script in python.

Can anyone offer any advice or things to try? Or is there a way I could get that pesky cmd window to stay open long enough for me to see what it says?

Thanks. My script is below.

import csv

def main():
iFileName = 'DonorsPlayTesting.csv'
oFileName = iFileName[:-4] + '-Output' + iFileName[-4:]
iFile = csv.DictReader(open(iFileName))
oFile = csv.writer(open(oFileName, 'w'), lineterminator = '\n')

iDirectory = csv.DictReader(open("DonorsDirectory.csv"))
oNames = {}
directory = {}
for line in iDirectory:
   directory[line['Number']] = line['Name']

for key in directory.keys():
    oNames[directory[key]] = 0

out_header = ['Name', 'Plays']
oFile.writerow(out_header)

for line in iFile:
    if line['Type'] == "Test Completion":
        if line['Number'] in directory:
            oNames[directory[line['Number']]] += 1
        elif line['Number'] not in directory:                
            oNames[line['Number']] = 'Need Name'


oFile.writerows(oNames.items())


main()

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top