-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsv.py
79 lines (62 loc) · 3.26 KB
/
sv.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import csv,os,urllib
import glob
from collections import defaultdict
def csvReview():
os.chdir(r'C:\Users\yourloc\Desktop\filescsv')
for file in glob.glob("*.csv"):
columns = defaultdict(list) # each value in each column is appended to a list
with open(file) as f:
reader = csv.DictReader(f) # read rows into a dictionary format
for row in reader: # read a row as {column1: value1, column2: value2,...}
for (k,v) in row.items(): # go over each column name and value
columns[k].append(v) # append the value into the appropriate list
# based on column name k
## if columns['Action'] == 'COMMENT_CHANGED':
## print columns['New value']
##print(columns['Date'])
##print(columns['User'])
##print(columns['Action'])
##print(columns['New value'])
##print columns['New value']
d = dict(zip(zip(columns['Date'],columns['User'],columns['New value']),columns['Action']))
##print rkdict
for key, value in d.iteritems():
if value == 'COMMENT_CHANGED' or value == 'COMMENT_ADDED':
print file,key
def csvComment():
'Module for data to be fetched and parsed into csv'
print 'started'
with open('sorted.txt', 'r') as f:
for line in f:
line = line.strip('\n')
durl='http://fisheye.com/cru/'+line+'/reviewHistory.csv'
print durl
testfile = urllib.URLopener()
testfile.retrieve('http://fisheye.com/cru/'+line+'/reviewHistory.csv', line+'.csv')
def csvFinalReview():
print 'started'
with open('sorted.txt', 'r') as f:
for line in f:
line = line.strip('\n')
durl='http://fisheye.com/cru/'+line+'/reviewHistory.csv'
print durl
testfile = urllib.URLopener()
testfile.retrieve('http://fisheye.com/cru/'+line+'/reviewHistory.csv', line+'.csv')
columns = defaultdict(list) # each value in each column is appended to a list
with open(line+'.csv') as f:
reader = csv.DictReader(f) # read rows into a dictionary format
for row in reader: # read a row as {column1: value1, column2: value2,...}
for (k,v) in row.items(): # go over each column name and value
columns[k].append(v) # append the value into the appropriate list
# based on column name k
d = dict(zip(zip(columns['Date'],columns['User'],columns['New value']),columns['Action']))
for key, value in d.iteritems():
if value == 'COMMENT_CHANGED' or value == 'COMMENT_ADDED':
print file,key
try:
os.remove(line+'.csv')
except IOError:
pass
#csvComment()
#csvReview()
csvFinalReview()