| 1 |
ninoborges |
8 |
## Dii_creator.py
|
| 2 |
|
|
## This program will create a summation dii file based on a matrix file supplied by the client.
|
| 3 |
|
|
## 06.13.03
|
| 4 |
|
|
## EBorges
|
| 5 |
|
|
|
| 6 |
|
|
import os, sys
|
| 7 |
|
|
|
| 8 |
|
|
def addToFile(batesNumb,fileName,endBatesNumb):
|
| 9 |
|
|
#print "file name = %s"% fileName
|
| 10 |
|
|
#print "batesNumb = %s"% batesNumb
|
| 11 |
|
|
#print "end Bates = %s"% endBatesNumb
|
| 12 |
|
|
w = open(r"C:\test_dir\wanda\output.dii",'a')
|
| 13 |
|
|
w.write("@T %s\n"%batesNumb)
|
| 14 |
|
|
w.write("@D @I\n")
|
| 15 |
|
|
w.write("%s\n"%fileName)
|
| 16 |
|
|
w.write("\n")
|
| 17 |
|
|
w.close()
|
| 18 |
|
|
if endBatesNumb:
|
| 19 |
|
|
ammend = open(r"c:\test_dir\wanda\output.dii",'r+')
|
| 20 |
|
|
ammend.seek(100,0)
|
| 21 |
|
|
ammend.write('@C EndDoc# %s\n'%endBatesNumb)
|
| 22 |
|
|
ammend.close()
|
| 23 |
|
|
#test = input("")
|
| 24 |
|
|
|
| 25 |
|
|
#r = open(r"c:\test_dir\wanda\from_vendor\PT01001.LOG",'r')
|
| 26 |
|
|
#r = open(r"c:\test_dir\wanda\from_vendor\CrossRef.txt",'r')
|
| 27 |
|
|
r = open(r"c:\test_dir\wanda\from_vendor\manny.txt",'r')
|
| 28 |
|
|
output = r.readlines()
|
| 29 |
|
|
r.close()
|
| 30 |
|
|
lastEntry = ""
|
| 31 |
|
|
lastBates = ""
|
| 32 |
|
|
for entry in output:
|
| 33 |
|
|
entry = entry.split(',')
|
| 34 |
|
|
print entry
|
| 35 |
|
|
if lastEntry == entry[0]:
|
| 36 |
|
|
print "%s is a duplicate file! Skipping."% entry[0]
|
| 37 |
|
|
else:
|
| 38 |
|
|
print "%s is new. Adding it to file..."% entry[0]
|
| 39 |
|
|
addToFile(entry[2],entry[0],lastBates)
|
| 40 |
|
|
print "%s has been added!"% entry[2]
|
| 41 |
|
|
lastEntry = entry[0]
|
| 42 |
|
|
lastBates = entry[2] |