I’ve got a CSV file that contains multiple data chunkds:
Alice
Age,Weight,Height
20y,50kg,170cm
Bob
Age,Weight,Height
22y,80kg,180cm
I need to load it into table PEOPLE in such way:
Name | Age | Weight | Height
Alice 20y 50kg 170cm
Bob 22y 80kg 180cm
Is it possible to do it with SQL*Loader?
Other way is to write a csv pre-processor on groovy for example, but it would be much better to solve it simply with SQl*Loader
Assuming you are on linux and or have access to
awk:So it prints a
create table ...statement in which you should replace your field lengths and tabblename. Then reads your CSV and on every line if the line does not contain any,it sets thenamevariable, then on everyAge,Weight,Heightline reads the next one and prints aninsertstatement with the contents (and acommit;). At the end it prints anexit;.At voila, you can load it with
sqlplus.Or rewrite it a bit to create a standard
csv, it’s easy.