generated from intersystems-community/objectscript-docker-template
-
Notifications
You must be signed in to change notification settings - Fork 9
/
iris_script.py
31 lines (25 loc) · 994 Bytes
/
iris_script.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
import glob
import os
import iris
import pandas as pd
from sqlalchemy import create_engine
from iris import ipm
# switch namespace to the %SYS namespace
iris.system.Process.SetNamespace("%SYS")
# set credentials to not expire
iris.cls('Security.Users').UnExpireUserPasswords("*")
# switch namespace to IRISAPP built by merge.cpf
iris.system.Process.SetNamespace("IRISAPP")
# load ipm package listed in module.xml
#iris.cls('%ZPM.PackageManager').Shell("load /home/irisowner/dev -v")
assert ipm('load /home/irisowner/dev -v')
# load demo data
engine = create_engine('iris+emb:///')
# list all csv files in the demo data folder
for files in glob.glob('/home/irisowner/dev/data/*.csv'):
# get the file name without the extension
table_name = os.path.splitext(os.path.basename(files))[0]
# load the csv file into a pandas dataframe
df = pd.read_csv(files)
# write the dataframe to IRIS
df.to_sql(table_name, engine, if_exists='replace', index=False, schema='dc_demo')