Hi,
I have a flat file containing data such as:
Orange Juice,1.25
Crisps,0.60
Diet Cola,0.75
I have a ksh script which I'm using to try and parse this file and load the data into a database. The path to the flat file is given as a parameter to the script and then each line is read in and passed to a stored procedure which takes the Item and value as parameters and loads these.
The problem is that my script works fine for entries like Crisps,0.60 but does not work for Orange Juice,1.25 as the space is causing a problem.
Can anyone help me get this to work properly?
Thanks,
tom
Script:
#!/usr/bin/bash
msg=`cat $1`
for I in $msg
do
my_array[0]=$(echo $I | cut -d',' -f1)
my_array[1]=$(echo $I | cut -d',' -f2)
sqlplus -s schema_name/schema_password@database|&
print -p "exec LOAD_SALESPRICE('${my_array[0]}',${my_array[1]});"
print -p "quit"
while read -p LINE
do
print - ${LINE}
done
done
exit 0
I have a flat file containing data such as:
Orange Juice,1.25
Crisps,0.60
Diet Cola,0.75
I have a ksh script which I'm using to try and parse this file and load the data into a database. The path to the flat file is given as a parameter to the script and then each line is read in and passed to a stored procedure which takes the Item and value as parameters and loads these.
The problem is that my script works fine for entries like Crisps,0.60 but does not work for Orange Juice,1.25 as the space is causing a problem.
Can anyone help me get this to work properly?
Thanks,
tom
Script:
#!/usr/bin/bash
msg=`cat $1`
for I in $msg
do
my_array[0]=$(echo $I | cut -d',' -f1)
my_array[1]=$(echo $I | cut -d',' -f2)
sqlplus -s schema_name/schema_password@database|&
print -p "exec LOAD_SALESPRICE('${my_array[0]}',${my_array[1]});"
print -p "quit"
while read -p LINE
do
print - ${LINE}
done
done
exit 0