Bryan,
Don't listen to those perl guys... ;-)
See below

On Tue, 18 Jan 2000, Gate wrote:

=> I need to do the following two things (separately):
=> 
=> First.. I have a file with comma delineated fields. The data in each field
=> is enclosed in double quotes ("). However, some data fields have a quote
=> within the quotes, and I need to remove that. What is my best choice for
=> this?

Ok,
*Assuming* Some_File looks like this:

"Junk_1","Junk_2","Junk"_3","Junk_4"
"Junk"_5","Junk_6","Junk_7","Junk_8"

Syntax without "points off"
quotes.awk < Some_File > Some_New_File

#!/usr/bin/gawk -f
# quotes.awk
# Input Data was:
# "Junk_1","Junk_2","Junk"_3","Junk_4"
# "Junk"_5","Junk_6","Junk_7","Junk_8"
BEGIN{
  FS=","
}
{
  for(x=1;x<=NF;x++){
    if(! match("\"[a-zA-Z0-9].*\"",$x) >0){
      gsub("^\"","",$x)
      gsub("\"$","",$x)
      gsub("\"","",$x)
    }
  }
        gsub(" ","\",\"",$0)
    printf "\"%s\"\n",$0
}
# end quotes.awk

=> 
=> Second.. A text file that contains data within brackets in this format:
=> useless text here[first/last]and useless text here
=> 
=> I need to just take the data "first" and "last" and output it into another
=> file like this:
=> first:last
=> 

Syntax:
cat Some_File | split.awk > Some_New_File
(probably get "points off" for the cat...<grin>)

#!/usr/bin/gawk -f
# split.awk
BEGIN{
  FS="["
}
{
  gsub("\\\].*$","",$2)
  split($2,fld,"/")
  printf "%s:%s\n",fld[1],fld[2]
}
# end split.awk

=> So whats the best idea for that? Any takers? :)
=> Thanks!
=> 
=>      Bryan
=> 
=> 
=> -- 
=> To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
=> as the Subject.
=> 
=> 

If you need me to mark up the scripts with # comments
email me offline and I'll send you the info.
We don't want to teach these new dogs "old tricks".. heh,heh..

Also, Might want to join us on the [EMAIL PROTECTED] list.

Have fun,
--
Rick L. Mantooth
[EMAIL PROTECTED]
The sooner you fall behind, the more time you'll have to catch up.




-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.

Reply via email to