Mac to Windows Python
Question: I have recently moved a set of near identical programs from my mac to my
school's windows, and while the paths appear to be the same (or the tail end
of them), they will not run properly.

    
    
    import glob
    import pylab
    from pylab import *
    
    
    def main():
        outfnam = "igdata.csv"
        fpout = open(outfnam, "w")
        nrows = 0
        nprocessed = 0
        nbadread = 0
        filenames = [s.split("/")[1] for s in glob.glob("c/Cmos6_*.IG")]
        dirnames = "c an0 an1 an2 an3 an4".split()
        for suffix in filenames:
            nrows += 1
            row = []
            row.append(suffix)
            for dirnam in dirnames:
                fnam = dirnam+"/"+suffix
                lines = [l.strip() for l in open(fnam).readlines()]
                nprocessed += 1
                if len(lines)<5:
                    nbadread += 1
                    print "warning: file %s contains only %d lines"%(fnam, len(lines))
                    tdate = "N/A"
                    irrad = dirnam
                    Ig_zeroVds_largeVgs = 0.0
                else:
                    data = loadtxt(fnam, skiprows=5)
                    tdate = lines[0].split(":")[1].strip()
                    irrad = lines[3].split(":")[1].strip()
                    # pull out last column (column "-1") from second-to-last row
                    Ig_zeroVds_largeVgs = data[-2,-1]
                row.append(irrad)
                row.append("%.3e"%(Ig_zeroVds_largeVgs))
            fpout.write(", ".join(row) + "\n")
        print "wrote %d rows to %s"%(nrows, outfnam)
        print "processed %d input files, of which %d had missing data"%( \
            nprocessed, nbadread)`
    

This program worked fine for a mac, but for windows I keep getting for :

    
    
     print "wrote %d rows to %s"%(nrows, outfnam)
        print "processed %d input files, of which %d had missing data"%( \
            nprocessed, nbadread)
    

wrote 0 row to file name processed 0 input files, of which o had missing data

on my mac i go 144 row to file...

does any one have any suggestions?


Answer: If the script doesn't raise any errors, this piece of code is most likely
returning an empty list.

    
    
    glob.glob("c/Cmos6_*.IG")
    

Seeing as glob.glob works perfectly fine with forward slashes on Windows, the
problem is most likely that it's not finding the files, which most likely
means that the string you provided has an error somewhere in it. Make sure
there isn't any error in `"c/Cmos6_*.IG"`.

If the problem isn't caused by this, then unfortunately, I have no idea why it
is happening.

Also, when I tried it, filenames returned by glob.glob have backslashes in
them on Windows, so you should probably split by `"\\"` instead.

