forked from CEFgoose/changesets2CSV-GUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCSV_EXPORT.py
36 lines (30 loc) · 1.22 KB
/
CSV_EXPORT.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
import csv
import os
from datetime import datetime, date, timedelta
def export_CSV(data,team_name,directory):
today = date.today()
csv_columns = ['name','username','user_id','role','Total Chagesets','Total Changes','Total Additions','Total Modified','Total Deleted','Misspelled Hashtags','Missing Hashtags',"Misspelled Comments"]
#cwd=os.getcwd()
csv_file = "%s_stats_%s.csv"%(team_name,today)
file_path=os.path.join(directory,csv_file)
try:
with open(file_path, 'w') as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=csv_columns)
writer.writeheader()
for data in data:
writer.writerow(data)
except IOError:
print("I/O error")
def construct_csv_data(main):
returnData=[]
if len(main.selected_user_ids)>1:
for i in main.selected_user_ids:
editor=main.team_dict[i]
obj=editor.construct_csv_data()
returnData.append(obj)
export_CSV(returnData,main.team_name,main.exportDirectory)
else:
editor=main.team_dict[main.selected_user_ids[0]]
obj=editor.construct_csv_data()
returnData.append(obj)
export_CSV(returnData,editor.name,main.exportDirectory)