Example:
Code: Select all
,,,"Pint, US liquid",PT,,,,
Thanks in advance!
Moderators: chulett, rschirm, roy
Code: Select all
,,,"Pint, US liquid",PT,,,,
Code: Select all
FUNCTION FixLine(TheLine, QuoteCharacter)
* Changes a comma-delimited line with embedded commas in quotes to a tab-delimited line
Equate Tab To Char(9)
Equate Comma To ","
String = TheLine
LenString = Len(TheLine)
WithinQuotes = @FALSE
Ans = ""
For Pos = 1 To LenString
Ch = String[Pos,1]
If Ch = QuoteCharacter
Then
WithinQuotes = Not(WithinQuotes)
End
Else
If Ch = Comma
Then
If WithinQuotes
Then
Ans := Comma
End
Else
Ans := Tab
End
End
Else
Ans := Ch
End
End
Next Pos
If WithinQuotes
Then
Call DSTransformError("Mismatched Quotes", "FixLine")
End
RETURN(Ans)
Code: Select all
,,,"Pint, US liquid",PT,,,,
Code: Select all
,,,"Pint, ""US"" liquid",PT,,,,