-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplitData-bing.py
More file actions
51 lines (43 loc) · 1.28 KB
/
splitData-bing.py
File metadata and controls
51 lines (43 loc) · 1.28 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# -*- coding: utf-8 -*-
"""
Created on Tue Jul 28 12:21:46 2015
@author: bling
"""
# read txt file
f = open('RawData0715_new.txt', 'r')
x = f.readlines()
#print x[1]
# turn txt file to list
tot = []
for i in x[1:]:
#print i.strip()
if i.strip():
tot.append(i.strip())
#print tot
Inspector=[]; TempDate=[]; InspectionDate=[]; RecordNum=[]; InspectionTime=[];
VehicheID=[]; Location=[]; Street=[]; City=[]; Zip=[]
for i in tot:
t = i.split('|')
#print t
Inspector.append(t[0]); TempDate.append(t[1]); RecordNum.append(t[2])
VehicheID.append(t[4]); Location.append(t[5])
Street.append(t[6]); City.append(t[7]); Zip.append(t[8])
#print Inspector
r=set(Inspector)
#print len(r)
for i in TempDate:
tu = i.split(' ')
#print tu
InspectionDate.append(tu[0]); InspectionTime.append(tu[1])
tou=[]
for i in xrange(len(Inspector)):
info= Inspector[i]+'|'+InspectionDate[i]+'|'+InspectionTime[i]+'|'+RecordNum[i]+'|'+VehicheID[i]+'|'+Location[i]+'|'+Street[i]+'|'+City[i]+'|'+Zip[i]
tou.append(info)
#print tou
for i in r:
files=open(i,'w')
files.write('Inspector|InspectionDate|InspectionTime|RecordNum|VehicheID|Location|Street|City|Zip\n')
for k in tou:
if k.find(i) != -1:
files.write(k+'\n')
files.close()