Parsing a comma delimited text file to a string
Posted on 2008-06-25
I have a routine text file that is supplied in comma delimited format. Each field is set off with quotation "" marks; however, the total columns are all grouped together in quotation marks, but are seperated with commas inside the quotation marks. I need to split these fields into an array so I can append to a table. I have attached my code that I am using to split the data, but I need something that goes inside the quotation marks and splits the data inside the quote marks. Keep in mind, I do have several circumstances where a last name and first name are together in quotation marks that need to have a comma between. A sample of my data is:
"Brown, John", "05/12/09", "111.32, 3432.11, 6325.21, 29383.22", "BP"
Do Until objFile.AtEndOfStream
StrFile = objFile.ReadLine
StrFile = Replace(StrFile, Chr(34), "")
ArrFile = Split(StrFile, ",")