-
Notifications
You must be signed in to change notification settings - Fork 0
/
combine_ad_createuser_v0.1
executable file
·40 lines (32 loc) · 1.32 KB
/
combine_ad_createuser_v0.1
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
#!/usr/bin/python
import time
import pandas as pd
import glob, os
# create directory everyday + global variable
COS_LIST='/opt/ams_smart/var/cos_list.csv'
CATALOG='/opt/ams_smart/var/catalog.csv'
datenow=(time.strftime("%Y-%m-%d"))
dirname=(time.strftime("%Y-%m-%d"))
OUT_ADEX='/SMART/CREATE/OUT/AD_STG/'
OUT_ADEX_TODAY=OUT_ADEX+dirname
OUT_ADEX_FIX='/SMART/CREATE/OUT/AD_FIX/'
OUT_ZM='/SMART/CREATE/OUT/ZM_STG/'
OUT_DB='/SMART/CREATE/OUT/DB_IMPORT/'
ERR_INFO='/SMART/CREATE/OUT/VALIDATION/'
ARCHIVE_AD='/SMART/CREATE/ARCHIVE/AD/'
ARCHIVE_AD_TODAY=ARCHIVE_AD+dirname+'/'
# FILE realtime
ADEX_FILE_FIX=OUT_ADEX_FIX +'/'+'adexchange-final-'+datenow+'.csv'
os.chdir(OUT_ADEX_TODAY)
results = pd.DataFrame([])
for counter, file in enumerate(glob.glob("*.csv")):
#namedf = pd.read_csv(file, skiprows=0, usecols=[1,2,3])
namedf = pd.read_csv(file, skiprows=0,usecols=['EmployeeNo','FirstName','LastName','DisplayName','UserLogonName','JobTitle','City','Office','Department','EnableMailbox','Manager'])
results = results.append(namedf)
#print (results)
#remove old file :
os.system("rm -rf "+ADEX_FILE_FIX+"/*.csv"+ ";echo 'file success and file aready removed..!'")
# insert new file
results.to_csv(ADEX_FILE_FIX,encoding='utf-8', index = None)
# archive file before remove
os.system("cp -rf " +ADEX_FILE_FIX+" "+ARCHIVE_AD_TODAY)