-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUntitled.py
48 lines (37 loc) · 1.36 KB
/
Untitled.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
import os
os.getcwd()
os.chdir('C:/Users/jingcong/Desktop/py')
import sys
import numpy as np
import pandas as pd
filename = sys.argv[1]
type_of_doc = sys.argv[2]
dsdc = pd.read_csv(filename)
concat_df = []
if type_of_doc == "c":
replaceDict = {"Training" : "Get Training","New Job":"Get Hired","Volunteering":"Volunteering","Teaching":"Give Training","Hiring":"Hiring","Speaking": "Event Speaking","Sponsoring":"Sponsoring","None":"None"}
def replaceVal(x):
helpValue = ''
temp = x
if not isinstance(x,str):
temp = "None"
line = temp.replace("\n","")
line_split = line.split(",")
for i in line_split:
if (i in replaceDict):
helpValue = replaceDict[i] + "," + helpValue
return helpValue
dsdc["What may we help you with?"] = dsdc["What may we help you with?"].apply(replaceVal)
if type_of_doc == "d":
dsdc['Name'] = dsdc['First Name'] + " " + dsdc['Last Name']
columnNames = ["Name","First Name","Last Name","Email","What may we help you with?","May we contact you?","Meetup ID"]
export_csv = pd.DataFrame()
for y in columnNames:
if y in dsdc.columns:
export_csv[y] = dsdc[y]
else:
export_csv[y] = ""
concat_df.append(export_csv)
final_df = pd.concat(concat_df)
final_df.to_csv("exported_"+type_of_doc+".csv",index=False)
print("done!\n")