to read a CSV file and generate SQL output

Friends,

This is what I need:

I will pass a CSV file as an input, and I want my shell to be reading that CSV file, and based on the parameters it should generate SQLs and write those SQL in a different file in the same location.

I'm new to Shell scripting. I'm currently working on a different technology. If somebody could help me, i am grateful.

Thanks,
Math

Hi Ram
You can try this

if ur csv file is like this

$ cat input.csv
razor,cts
indu,adobe
akash,daksh

u can use this code

 awk -F',' '{ print "Select * from " $1 " where user=" $2 ";" }' input.csv > output.log

$ cat output.log
Select * from razor where user=cts;
Select * from indu where user=adobe;
Select * from akash where user=daks;

hope it will help

1 Like