How to reformat text
"Gary Kuznitz" <[email protected]>
| Newsgroups | gmane.comp.windows.autoit.user |
|---|---|
| Message-ID | <[email protected]> |
I'm wondering if anyone is up for a challenge ?
I have records that have @CRLF in the middle of the record. I need a way to read
those in. This is an example of one record:
|LastName,%-FirstName,"Address1
Address2",City,State,ZipCode,Country,,,,,,,,,,,,,Home,Home,Work,Work,Cell1,Cellular
,Fax,Fax,Email1,E-mail,Email2,E-mail,,,,,"Divorced
Died"
It's on separate lines because of the CRLF.
Excel reads it as one record.
I tried doing a FileReadLine but it reads it in as multiple lines. I tried doing a
_FileReadToArray but it reads it in as multiple lines also.
I'm thinking I need a couple loops to look for " and read another record if there is
only one to build the record back together.
This is what I have so far:
Dim $BuildRecord
Global $file_array[1]
$CSVfile = FileOpen("address 07-06-08.csv", 0)
; Check if file opened for reading OK
If $CSVfile = -1 Then
MsgBox(0, "Error", "Unable to open address 07-06-08.csv file.")
Exit
EndIf
; Read in lines of text until the EOF is reached
While 1
$RawLine = FileReadLine($CSVfile)
If @error = -1 Then
$file_array[0] = Ubound($file_array)-1
ExitLoop
EndIf
MsgBox(0, "RawLine", $RawLine)
; Put $RawLine into $BuildRecord
; If " is found look for second quote
; If second quote is not found read $RawLine
; Replace CR with something
; Replace LF with something
; Add $RawLine to the end of $BuildRecord
; Continue looking for second quote
_ArrayAdd($file_array, $BuildRecord)
Wend
FileClose($CSVfile)
Is anyone up for the challenge?
Thank you,
Gary Kuznitz