[...] where I start getting some errors.
I'm hoping I won't have to post my code
"Doctor, I'm feeling bad. I hope I won't have to tell you my
symptoms. What do I have?"
Please provide the actual errors and the actual code. It is easier,
less error prone and more useful to copy and paste them instead of
writing some pseudocode. Maybe the repeated index i is a typo you
made when writing this post and the original code is correct, but we
don't have any way to know that.
Here is my code, in the hopes that there is a reason why it isn't
running. Thanks guys.
Option Explicit - 'Sorry so use to writing this!
import os, string
# Get filename to work with
workspace = "c:\\temp"
filename = "\AVC1030708.14"
doc1 = workspace + filename
onedoc = open(doc1, "r")
rdoc1 = onedoc.read()
doclist1 = string.split(rdoc1, "\n")
for i in range(8):
doclist1.pop(0)
length = int(len(newlist1))-2
Nscheme = int(filename[12:14])
numlanes = length/Nscheme
site = filename[4:7]
year = filename[7:9]
month = filename[9:11]
Sscheme = str(Nscheme)
# Get Master AVC Table for Lanes & Direction
fileavc = "\AVCMaster"
doc2 = workspace + fileavc
twodoc = open(doc2, "r")
rdoc2 = twodoc.read()
doclist2 = string.split(rdoc2, "\n")
doclist2.pop(0)
# Dictionary of Zeros to add to Class Fields
addzeros = {1:"0", 2:"00", 3:"000", 4:"0000"}
while doclist1:
list1 = doclist1[0]
doclist1.pop(0)
newlist1 = list1.split(",")
date1 = newlist1[0]
if len(newlist1[0])== 8:
day = date1[2:3]
else:
day = date1[2:4]
if len(day)>1:
day = "0" +1
hour = newlist1[1]
lanex = []
# Find number of Lanes & Fields
if numlanes == 2:
lane1 = newlist1[2:2+Nscheme]
lanex.append(lane1)
lane2 = newlist1[2+Nscheme:2+Nscheme*2]
lanex.append(lane2)
else:
lane1 = newlist1[2:2+Nscheme]
lanex.append(lane1)
lane2 = newlist1[2+Nscheme:2+Nscheme*2]
lanex.append(lane2)
lane3 = newlist1[2+Nscheme*2:2+Nscheme*3]
lanex.append(lane3)
lane4 = newlist1[2+Nscheme*3:2+Nscheme*4]
lanex.append(lane4)
doctemp = doclist2
listtemp = doctemp[0]
avclist = listtemp.split(",")
while site <> avclist[0]:
doctemp.pop(0)
listtemp = doctemp[0]
avclist = listtemp.split(",")
dirx = []
fhlanex = []
dirx.append(avclist[2])
fhlanex.append(avclist[3])
dirx.append(avclist[5])
fhlanex.append(avclist[6])
if avclist[8] <> "0":
dirx.append(avclist[8])
fhlanex.append(avclist[9])
dirx.append(avclist [11])
fhlanex.append(avclist[12])
for x in range(1, numlanes+1):
avcclass = []
Nlanex = []
for i in range(1,Nscheme+1):
numzeros = 5 - int(len(lanex[i-1]))
avcclass.append(addzeros[numzeros] + lanex[i-1])
Nlanex.append(int(lanex[i-1])
lanex.pop(0)
totalclass = sum(Nlanex)
Stotalclass = str(totalclass)
#Create 90 Character File for SAS Job
classsum = avcclass[0] + avcclass[1] + avcclass[2] +
avcclass[3] + avcclass[4] + avcclass[5] \
+ avcclass[6] + avcclass[7] + avcclass[8] + avcclass[9] +
avcclass[10] \
+ avcclass[11] + avcclass[12] + avcclass[13]
classmn = "C27" + site + dirx[x] + lanex[x] + year + month +
day + hour + Stotalclass + classsum
break
avcsasdoc = workspace + "\avcsas.txt"
fdoc = open(avcsasdoc, "w")
fdoc.write(classmn)