Quote:

is the logic sound



No.

It really is far more complicated than that.

If you are willing to forego the country / postcode stuff, this will get you pretty much there:
Code:
 
$sInputFile=".\demo.txt"
$sOutputFile=".\demo.csv"

$sDelim=Chr(10)

$fdInputFile=FreeFileHandle()
If Open($fdInputFile,$sInputFile)
"Cannot open file"+$sInputFile+"' for input"+@CRLF
"Reason: ["+@ERROR+"] "+@SERROR+@CRLF
Exit @ERROR
EndIf

If Exist($sOutputFile) Del $sOutputFile EndIf

$fdOutputFile=FreeFileHandle()
If Open($fdOutputFile,$sOutputFile,4+1)
"Cannot open file"+$sOutputFile+"' for output"+@CRLF
"Reason: ["+@ERROR+"] "+@SERROR+@CRLF
Exit @ERROR
EndIf

$sIn=ReadLine($fdInputFile)
While Not @ERROR
Select
Case $sIn=""
; Blank line - ignore
Case InStr($sIn,"FAX:")=1
$sFax=Trim(SubStr($sIn,5))
; Write out record.
@CRLF+"Person ="$sPerson+@CRLF
$=WriteLine($fdOutputFile,SubStr(udfFixField($sPerson),2))
$asAddress=Split(SubStr($sAddress+$sDelim+$sDelim+$sDelim+$sDelim,2),$sDelim)
For $iIndex = 0 to 4
"Address "+($iIndex+1)+" ="$asAddress[$iIndex]+@CRLF
$=WriteLine($fdOutputFile,udfFixField($asAddress[$iIndex]))
Next
"Telephone ="$sTel+@CRLF
$=WriteLine($fdOutputFile,udfFixField($sTel))
"Fax ="$sFax+@CRLF
$=WriteLine($fdOutputFile,udfFixField($sFax))
$=WriteLine($fdOutputFile,@CRLF)
$sLast=""
$sAddress=""
$sTel=""
$sFax=""
Case InStr($sIn,"TEL:")=1
$sPerson=$sLast
$sTel=Trim(SubStr($sIn,5))
Case "Default"
If $sLast<>"" $sAddress=$sAddress+$sDelim+$sLast EndIf
$sLast=$sIn
EndSelect
; Catenate line, fix speech marks to braindead MS csv style
;If $sIn <> "" $sOut=$sOut+',"'+Join(Split($sIn,'"'),'""')+'"' EndIf
;If InStr($sIN,"FAX: ")==1 $=WriteLine($fdOutputFile,SubStr($sOut,2)+@CRLF) $sOut="" EndIf
$sIn=ReadLine($fdInputFile)
Loop

If $sOut <> "" $=WriteLine($fdOutputFile,SubStr($sOut,2)+@CRLF) $sOut="" EndIf

$=Close($fdInputFile)
$=Close($fdOutputFile)

Exit 0

Function udfFixField($s)
$udfFixField=',"'+Join(Split($s,'"'),'""')+'"'
EndFunction



This creates the CSV and dumps some debug text to the screen.

The debug text for your sample looks like this:
Quote:

Person =Sarah Tunnadine
Address 1 =BROOK HOTELS
Address 2 =The Coach House
Address 3 =High Street
Address 4 =Sevenoaks
Address 5 =KentTN131HY
Telephone =0800 435165
Fax =01732 741041

Person =Aphrodite Burton
Address 1 =CHOICE HOTELS EUROPE
Address 2 =Premier House
Address 3 =112 Station Road
Address 4 =Edgware
Address 5 =Middx HA8 7BJ
Telephone =020 8233 2001
Fax =020 8233 2075

Person =Marketing Department
Address 1 =CONCORDE HOTELS
Address 2 =Grosvenor Gardens House
Address 3 =35/37 Grosvenor Gardens
Address 4 =London SW1W0BS
Address 5 =
Telephone =0800 028 9881
Fax =020 7630 0391

Person =Alison Gray
Address 1 =DEVERE HOTELS
Address 2 =& LEISURE LTD
Address 3 =2100 Daresbury Park
Address 4 =Daresbury, Warrington
Address 5 =Cheshire WA4 4BP
Telephone =0870 240 0101
Fax =01928 756 440

Person =Greg McCreadv
Address 1 =GRAND HERITAGE HOTELS
Address 2 =Central Booking Agency
Address 3 =1st Floor Warwick House
Address 4 =181-183 Warwick Road
Address 5 =London W14 8PU
Telephone =020 7244 6699
Fax =020 7244 7799

Person =Jan
Address 1 =GRANGE HOTELS
Address 2 =58 Rochester Row
Address 3 =London SW1 1JU
Address 4 =
Address 5 =
Telephone =020 7233 7373
Fax =020 7835 1888

Person =Robert Hughes
Address 1 =IMPNEY HOTELS
Address 2 =The Chateau Impney Hotel
Address 3 =Droitwich Spa
Address 4 =Worcs WR9 0BN
Address 5 =
Telephone =01905 774411
Fax =01905 772371

Person =Stephanie Segouta
Address 1 =INTER-CONTINENTAL
Address 2 =& FORUM HOTELS
Address 3 =Mayfair Inter-Continental Hotel
Address 4 =Stratton Street
Address 5 =London W1A 2AN
Telephone =020 7629 7777
Fax =020 7409 7016

Person =Stephen Crawley
Address 1 =LAYTONA LEISURE GROUP
Address 2 =Mendip Lodge Hotel
Address 3 =Bath Road
Address 4 =Frame
Address 5 =Somerset BA11 2HP
Telephone =01373 454211
Fax =01373 471618




The CSV file looks like this:
Quote:

"Sarah Tunnadine","BROOK HOTELS","The Coach House","High Street","Sevenoaks","KentTN131HY","0800 435165","01732 741041"
"Aphrodite Burton","CHOICE HOTELS EUROPE","Premier House","112 Station Road","Edgware","Middx HA8 7BJ","020 8233 2001","020 8233 2075"
"Marketing Department","CONCORDE HOTELS","Grosvenor Gardens House","35/37 Grosvenor Gardens","London SW1W0BS","","0800 028 9881","020 7630 0391"
"Alison Gray","DEVERE HOTELS","& LEISURE LTD","2100 Daresbury Park","Daresbury, Warrington","Cheshire WA4 4BP","0870 240 0101","01928 756 440"
"Greg McCreadv","GRAND HERITAGE HOTELS","Central Booking Agency","1st Floor Warwick House","181-183 Warwick Road","London W14 8PU","020 7244 6699","020 7244 7799"
"Jan","GRANGE HOTELS","58 Rochester Row","London SW1 1JU","","","020 7233 7373","020 7835 1888"
"Robert Hughes","IMPNEY HOTELS","The Chateau Impney Hotel","Droitwich Spa","Worcs WR9 0BN","","01905 774411","01905 772371"
"Stephanie Segouta","INTER-CONTINENTAL","& FORUM HOTELS","Mayfair Inter-Continental Hotel","Stratton Street","London W1A 2AN","020 7629 7777","020 7409 7016"
"Stephen Crawley","LAYTONA LEISURE GROUP","Mendip Lodge Hotel","Bath Road","Frame","Somerset BA11 2HP","01373 454211","01373 471618"