![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Calling a perl script from a perl script | new2ss | Shell Programming and Scripting | 6 | 05-24-2009 05:03 PM |
| Include PERL script with in the unix shell script | ganapati | UNIX for Dummies Questions & Answers | 1 | 04-29-2008 12:18 PM |
| here document to automate perl script that call script | hogger84 | Shell Programming and Scripting | 3 | 10-22-2007 10:15 AM |
| Modify Perl script to work with txt - Permissions script | joangopan | Shell Programming and Scripting | 1 | 09-12-2007 11:38 PM |
| Perl: Run perl script in the current process | vino | Shell Programming and Scripting | 10 | 12-09-2005 10:45 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Hi All,
I would need to generate Oracle Inster scripts from an excel formatted spreadsheet as follows: Quote:
Quote:
REC 1, REC 2 etc are the separators of the records ... I beleive a pearl script can be written for this ... anything useful will be of great help. Thanks in Advance Sabya |
|
||||
|
Hello Radoulov,
Thanks for your reply and sorry for my lack of knowledge in awk. I am using solaris 10 - I have tried as follows: I have created a script : chk.awk Quote:
While I am calling the script - I am getting the following error: Quote:
|
|
||||
|
Radoulov has given you the complete awk command!! (you should be more observent)
In your form of execution, take out the awk and the single quote from the begin & end of the command in your script-file. |
|
|||||
|
Change the script like this:
Code:
#! /usr/xpg4/bin/awk -f
END {
printf fmt, ++c, tab, cols, values
}
NR == 1 {
tab = $1
fmt = "REC %d: INSERT INTO %s(%s)\nVALUES\n(%s);\n"
FS = " *: *"
q = "'"
next
}
/^REC/ && cols {
printf fmt, ++c, tab, cols, values
cols = ""
values = ""
next
}
{
$2 = $2 ~ /^[0-9]/ ? $2 : q $2 q
cols = cols ? cols "," $1 : $1
values = values ? values "," $2 : $2
}
Code:
./script datafile |
|
||||
|
Thanks Radoulov and Unilover
![]() Works like a charm. Just a small glitch ... - not so much proficient to debug and fix the problem ...Everything (all the other records) is coming out except the first record. The output is coming like: Quote:
Quote:
Other than the first record - all other records are coming absolutely fine. Thanks again, Sabya |
| Sponsored Links | ||
|
|