-
Notifications
You must be signed in to change notification settings - Fork 4
/
FixFieldSheet.py
34 lines (29 loc) · 1001 Bytes
/
FixFieldSheet.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
root = "C:\\Users\\BCBrown\\Box\\AbbottLab\\Data\\FieldSheets\\"
inFile = "MasterFieldbook200603.csv"
outFile = "CorrectedMasterFieldboko200604.csv"
def fixDate(date):
date = date.replace("/","-")
day, month, year = date.split("-")
if len(year) == 2:
year = int(year)
year = year + 2000
year = str(year)
fixedDate = year + "-" + month + "-" + day
return fixedDate
with open(root + outFile, "w+") as oFile:
with open(root + inFile, "r+") as iFile:
i = 0
for line in iFile:
if i > 1:
line = line.replace("\n","")
line = line.split(",")
print(line)
date = line[2]
if date != "":
fixedDate = fixDate(date)
line[2] = fixedDate
outLine = ",".join(line)
outLine = outLine + "\n"
oFile.write(outLine)
print(i)
i = i + 1