Note that there are some explanatory texts on larger screens.

plurals
  1. POcreating an exe out of a small Python script
    primarykey
    data
    text
    <p>I created a small script using Python 2.7.</p> <p>Using py2exe I have been trying to create an executable using <a href="http://www.py2exe.org/index.cgi/Tutorial" rel="nofollow">this tutorial</a>:</p> <p>I am able to create the exe file called <code>sdf.exe</code></p> <p>I have all the necessary libraries in the directory with sdf.exe.</p> <p>From the command line when I run sdf.exe, I get no errors and no messages; however the program does not do what it is intended to do which is to create a file called <code>output.csv</code>.</p> <p><strong>When I run <code>sdf.py</code> it works without a problem; however, running <code>sdf.exe</code> does nothing and returns no errors.</strong></p> <p>What am I missing? thank you so much!</p> <p>Here's the full code:</p> <pre><code>import csv thefile = [] output = [] def dowork(): global thefile sourceFile='e.csv' thefile=ReadFile(sourceFile) CleanFile(sourceFile) ProcessFile() AddHeader() WriteFile() def ReadFile(filename): return list(csv.reader(open(filename, 'rb'), delimiter=',', quotechar='"'))[1:] def CleanFile(sourceFile): global thefile iBalance=8 iAging=7 thefiletmp=[] for i, line in enumerate(thefile): if line[2]=='': del thefile[i] else: if thefile[i][iAging]=='': thefile[i][iAging]='0' thefiletmp.append(line[4:]) thefile=thefiletmp def ProcessFile(): global thefile iCompany=1 iNum=0 iDate=2 iAging=3 iBalance=4 COMPANIES=GetDistinctValues(1) mytemparray=[] mytempfile=[] TotalEachCustomer=0 for company in COMPANIES: for line in thefile: if line[iCompany]==company: mytemparray.append(line[iCompany]) mytemparray.append(line[iNum]) mytemparray.append(line[iDate]) iAgingCell=int(line[iAging]) line[iBalance]=line[iBalance].replace(',','') if iAgingCell in range(0,31): mytemparray.append(line[iBalance]) mytemparray.append('0') mytemparray.append('0') mytemparray.append('0') if iAgingCell in range(31,61): mytemparray.append('0') mytemparray.append(line[iBalance]) mytemparray.append('0') mytemparray.append('0') if iAgingCell in range(61,91): mytemparray.append('0') mytemparray.append('0') mytemparray.append(line[iBalance]) mytemparray.append('0') if iAgingCell &gt;90: mytemparray.append('0') mytemparray.append('0') mytemparray.append('0') mytemparray.append(line[iBalance]) TotalEachCustomer+=float(line[iBalance]) mytemparray.append(line[iBalance]) mytempfile.append(mytemparray) mytemparray=[] mytempfile.append(['','','','','','','','']) mytempfile.append([company+ " Total",'','','','','','',TotalEachCustomer]) mytempfile.append(['','','','','','','','']) TotalEachCustomer=0 thefile=mytempfile def AddHeader(): global thefile thefile[:0]=[['Account Name', 'Num','Date', '0-30', '31-60', '61-90', '91 Plus','Total']] def WriteFile(): global thefile out_file = open("output.csv", "wb") writer = csv.writer(out_file) for line in thefile: writer.writerow(line) out_file.close() def GetDistinctValues(theColumn): return sorted(list(set(line[theColumn] for line in thefile))) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload