Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Xbase Fox > Re: Parsing a S...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 9 Topic 846 of 861
Post > Topic >>

Re: Parsing a String

by "MikeA" <appell@[EMAIL PROTECTED] > Jun 19, 2008 at 05:41 AM

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.
 




 9 Posts in Topic:
VFP9: Parsing a String
Gene Wirchenko <genew@  2008-06-18 19:58:06 
Re: VFP9: Parsing a String
Jack Jackson <jjackson  2008-06-18 22:29:17 
Re: VFP9: Parsing a String
"MikeA" <app  2008-06-19 05:53:58 
Re: VFP9: Parsing a String
Gene Wirchenko <genew@  2008-06-19 08:25:38 
Re: Parsing a String
"MikeA" <app  2008-06-19 05:41:53 
Re: Parsing a String
"Olaf Doschke"   2008-06-19 08:23:37 
Re: Parsing a String
"Olaf Doschke"   2008-06-19 08:33:38 
Re: Parsing a String
"MikeA" <app  2008-06-19 06:39:58 
Re: Parsing a String
"Des" <des@[  2008-06-19 08:52:02 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Dec 5 10:51:04 CST 2008.