Hi Team,
I m new to python and started working on basics but cant get through when the problem goes to next level.
I have data looks like below and attached but I need to generate create statements out of CSV rows.
DB SCH TAB COL
DEV SCOTT EMP EMPNO
DEV SCOTT EMP ENAME
DEV SCOTT EMP DEPTNO
DEV SCOTT DEPT DEPTNO
DEV SCOTT DEPT DNAME
DEV SCOTT DEPT LOC
I want to generate 1 file for each table
CREATE VIEW SCOTT.EMP_V
AS
SELECT
EMPNO,
ENAME,
DEPTNO
FROM
SCOTT.EMP; --> This output is routed to EMP_V.sql file
CREATE VIEW SCOTT.DEPT_V
AS
SELECT
DEPTNO,
DNAME,
LOC
FROM
SCOTT.DEPT; --> This output is routed to DEPT_V.sql file
I am browsing through list and dictionaries and trying to do in parallel.
df = pd.read_csv("view.csv")
print(df)
df1=df.groupby(['DB','TAB'])['COL'].apply(','.join)
print(df1)
df2 = df1.reset_index(name = 'COLS')
print(df2)
Any better inputs are appreciated.
Please let me know
I m new to python and started working on basics but cant get through when the problem goes to next level.
I have data looks like below and attached but I need to generate create statements out of CSV rows.
DB SCH TAB COL
DEV SCOTT EMP EMPNO
DEV SCOTT EMP ENAME
DEV SCOTT EMP DEPTNO
DEV SCOTT DEPT DEPTNO
DEV SCOTT DEPT DNAME
DEV SCOTT DEPT LOC
I want to generate 1 file for each table
CREATE VIEW SCOTT.EMP_V
AS
SELECT
EMPNO,
ENAME,
DEPTNO
FROM
SCOTT.EMP; --> This output is routed to EMP_V.sql file
CREATE VIEW SCOTT.DEPT_V
AS
SELECT
DEPTNO,
DNAME,
LOC
FROM
SCOTT.DEPT; --> This output is routed to DEPT_V.sql file
I am browsing through list and dictionaries and trying to do in parallel.
df = pd.read_csv("view.csv")
print(df)
df1=df.groupby(['DB','TAB'])['COL'].apply(','.join)
print(df1)
df2 = df1.reset_index(name = 'COLS')
print(df2)
Any better inputs are appreciated.
Please let me know
Attached Files