The perennial question: Does anybody have a utility for merging or
updating bbdb?

I wrote a crude awk script to create a bunch of elisp
        `(bbdb-create-internal...'
commands from a file containing entries formatted such as:
        "157"\"(213)259-3824"\"Atasoy"\"Levent"\"N"\"Levent"\"MSC/N Prod 
Mgmt"\"LAB2"\"LA-825 Colorado Bl., 2nd Floor"\"levent.atasoy"

The awk script is given below, if anyone wants to hack it for own use.
My problem is that now I have to update the bbdb. New entries are
easy. I could seperate them and use the same creation stuff. But
adding new fields or updating the existing entries is problematic.

Does any one have any code to help me? For instance something similar to
 `(bbdb-create-internal "NAME"..' but would create a new field for
that name would be helpful.

Thanks

=====================

#(bbdb-create-internal "NAME" "COMPANY" '("NET1") '(["ADR DESCR" "ST1" "ST2" "" "CITY" 
"STATE" 99999]) '(["LOC" 213 111 2222 0] ["LOC2" 213 333 4444 0]) "COMMENTS")
#nawk -f $HOME/bin/bbdbconvert.awk $HOME/o/tel/msc


BEGIN { FS = "\\" }

{

if ( $5  == "\"\"" ) {
  FULLNAME=substr($4,1,length($4)-1) " " substr($3,2,length($3)-1) ;
}
else {
  FULLNAME=substr($4,1,length($4)-1) " " substr($5,2,length($5)-2) " " 
substr($3,2,length($3)-1) ;
}


TELLOC="\"tel\"" ;
TELSTR=$2 ;

COMPANY="\"mycomp\"" ;

if ( $10  == "\"\"" ) {
  NAME=substr($4,1,length($4)-1) " " substr($3,2,length($3)-1) ;
  EMAIL=substr($3,1,length($3)-1) "_" substr($4,2,length($4)-1) ;
}
else {
  EMAIL=$10 ;
  idx=index(EMAIL,".");
  ENAME= "\"" toupper(substr(EMAIL,2,1)) substr(EMAIL,3,idx-3);
  ELNAME= toupper(substr(EMAIL,idx+1,1)) substr(EMAIL,idx+2,100);
  NAME=ENAME " " ELNAME;
  EMAIL="\"" toupper(substr(EMAIL,2,1)) "_" toupper(substr(EMAIL,idx+1,1)) 
substr(EMAIL,idx+2,100) " " EMAIL;
}

ADRLOC="\"location\"" ;
STR1=$9 ;
STR2="\"\"" ;
STR3="\"\"" ;
CITY=$8 ;
STATE="\"\"" ;
ZIP="nil" ;

COMMENTS="(quote((Department . " $7 ;
if ( NAME != FULLNAME ) COMMENTS=COMMENTS ")(Full_Name . " FULLNAME ;
COMMENTS=COMMENTS ")(Employee_No . " $1 ")))";

print "(bbdb-create-internal " NAME " " COMPANY " (list " EMAIL ") (vector[" ADRLOC " 
" STR1 " " STR2 " " STR3 " " CITY " " STATE " " ZIP "]) (vector[" TELLOC " " TELSTR  
"]) " COMMENTS ")" 
}


Reply via email to