Hi Gene:
If you don't have to worry about quotes or CRLF then you could easily use
STRTRAN. Otherwise, here are my comments:
Well, for starters, your example could be somewhat faulty and here's why.
True "comma delimted" as I'm sure you know actually uses quotes so as to
allow commas in a field. Therefore, your example being surrounded by
quotes
(if that is how you intended it to be) would actually span only the first
field. I'm sure you probably know this but I'm just clarifying for those
who do not. So, "abc,,def,ghi," is very different from abc,,def,ghi,
If there could be quotes and/or CRLF then it can get really tricky. For
one
thing, you could use an APPEND FROM with the CSV into a cursor with a lot
of fields. However, VFP does not like CRLF in fields and does not take
that
into account with Append From. If that is the case they you have to write
your own function. In other words if the fields are say
FirstName,LastName,Notes and you have something like this:
Jon,Doe,A very nice person
Jane,Doe,"A nice person, but sometimes not so nice"
Jan,Smith,"Very nice person, and she works hard, and
she is a good programmer and most im****tant of all
She loves VFP"
Jane,Smith,A nice person
So, in my CSV example I have embedded commas as well as CRLF in quotes.
I'm
not sure what your situation is but for CRLF in quotes, you are going to
just have to write your own function. Should not be too hard but it could
be kind of a PITA especially if the file is more than 16 megs which
requires
a low level read unless you just im****t the whole thing in a table and
then
read the fields in a function. Yep, a PITA but not hard to program.just
your basic "dirt work" that you wish were in one easy function. Unless
they
have changed the Append From CSV in VFP 9 (which I doubt) it's going to
require a function AFAIK.
Mike
If you are sure there will not be any quotes surrounding the fields then
you
can easily use the STRTRAN function.
"Gene Wirchenko" <genew@[EMAIL PROTECTED]
> wrote in message
news:aiij54pbe3fvklbcmsr0klsdantebs4skq@[EMAIL PROTECTED]
> Is there a function for parsing a comma-delimited string into an
> array of substrings? I thought there was, but I can not find it in
> the docs.
>
> Example: "abc,,def,ghi," would return an array of elements:
> "abc"
> ""
> "def"
> "ghi"
> ""
>
> Sincerely,
>
> Gene Wirchenko
>
> Computerese Irregular Verb Conjugation:
> I have preferences.
> You have biases.
> He/She has prejudices.


|