Is there a way to load data from a flat file to an oracle table. I am using following python code but the file is too big and the script stops after sometime (due to lost db connection).
from tqdm import tqdm
insert_sty = "insert into MRSTY (CUI,TUI,STN,STY,ATUI,CVF) values (:0,:1,:2,:3,:4,:5)"
records=[]
file_path = "../umls_files/umls-2023AA-metathesaurus-full/2023AA/META/MRSTY.RRF"
num_lines = sum(1 for line in open(file_path))
with open(file_path, 'r') as f:
for line in tqdm(f, total=num_lines, desc="Processing file"):
line = line.strip()
records.append(line.split("|"))
for sublist in records:
if sublist:
sublist.pop()
for i in tqdm(records, desc="Inserting records"):
try:
cur.execute(insert_sty,i)
print ("record inserted")
except Exception as e:
print (i)
print("Error: ",str(e))
conn.commit()