Hi.
I have a set of comma separated files which I need to split into arrays. The problem is that the format of the file is mixed text and numeric. The text fileds are double quoted, and may have commas inside! The numbers are not double quoted. Also, som fields are empty. (not even a space between the commas).
So what I start with will be like this:
"field 1",2.32,"Field 3 has commas, etc",,"Field 5"
And I want to end up with:
$var[0]="field 1"
$var[2]="2.32"
$var[3]="Field 3 has commas, etc"
$var[4]=""
$var[5]="Field 5"
and so on. (with the quotes stripped off). I can do this in a time consuming way, but can anyone advise me of a quick method (I have to decode about a million CSV fields per run for this project, and my existing code takes about 3 hours).
Many thanks.
I have a set of comma separated files which I need to split into arrays. The problem is that the format of the file is mixed text and numeric. The text fileds are double quoted, and may have commas inside! The numbers are not double quoted. Also, som fields are empty. (not even a space between the commas).
So what I start with will be like this:
"field 1",2.32,"Field 3 has commas, etc",,"Field 5"
And I want to end up with:
$var[0]="field 1"
$var[2]="2.32"
$var[3]="Field 3 has commas, etc"
$var[4]=""
$var[5]="Field 5"
and so on. (with the quotes stripped off). I can do this in a time consuming way, but can anyone advise me of a quick method (I have to decode about a million CSV fields per run for this project, and my existing code takes about 3 hours).
Many thanks.