-
Notifications
You must be signed in to change notification settings - Fork 4
/
testingTools.py
27 lines (25 loc) · 924 Bytes
/
testingTools.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
import os
def multipleOutputSim(path):
initialCwd=os.getcwd()
os.chdir(path)
files = [f for f in os.listdir('.') if os.path.isfile(f)]
outFileStrs = dict()
for inFileName in files:
with open(inFileName) as inFile:
for line in inFile:
pathKey,val = line.replace('"',"").strip().split("\t")
path,key = pathKey.split("|")
# print line
# print path,key,val
if not path in outFileStrs:
outFileStrs[path]=[key+"\t"+val]
else:
outFileStrs[path].append( "\n"+key+"\t"+val )
for path in outFileStrs:
# print os.getcwd()
# print path
if not os.path.exists(path):
os.makedirs(path)
with open(path+"/part-00000","w") as outFile:
outFile.write( "".join(outFileStrs[path]) )
os.chdir(initialCwd)