-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload.py
More file actions
31 lines (27 loc) · 878 Bytes
/
load.py
File metadata and controls
31 lines (27 loc) · 878 Bytes
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
import sys
import getopt
import jdbe
import profiles as p
from ConfigParser import ConfigParser
def usage():
print ("\npython load.py [OPTION...] [FILE...] [+LINE[:COLUMN]] = loads CSV profiles\n\n")
print ("-h --help usage()")
print ("-P --ProductProfile <ProductProfile.csv> = loads Product Profile")
try:
opts, args = getopt.getopt(sys.argv[1:], 'P:h', ['ProductProfile=', 'help'])
config = ConfigParser()
config.read('data/JDBE_local.ini')
db = jdbe.jdbe('data/JDBE_local.ini')
db.start()
except getopt.GetoptError:
sys.exit(2)
for opt, arg in opts:
try:
if opt in ('-h', '--help'):
usage()
elif opt in ('-P', '--ProductProfile'):
prodfile = arg
pfile = open(prodfile, 'rt')
p.ProductProfile_create(db, pfile)
except Exception as e:
print e