Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Ctrl linefeeds embedded in CSV field
Message
From
19/10/2010 13:45:36
 
 
To
19/10/2010 12:27:07
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01486146
Message ID:
01486167
Views:
51
>Decided the best way to munge csv files I'm getting Adobe pdf exports is the Fox, but I'm running into problem with memo-type files Adobe is exporting that contain chr(10)+chr(13).
>
>When the csv comes into excel, the field shows as multiple lines. When I try to use that same csv for appending to a VFP dbf, the ctrl linefeed pair is of course seen as the end of the record. I've been massaging the csv using fox's wonder filetostr and strtofile. Problem is i can't figure out how to distinguish between the embedded pairs which I i would like to just replace with "----" or something until I can get them into a VFP memo field and put the linefeeds back and the pairs at the end of a record.
>
>I could live with a technique in Excel that would let me replace the linefeeds in the cells in that column ( I know *nothing* about Excel ) and then export the resulting massaged xls as a csv.
>
>Would welcome any suggestions. There are about 10 columns with this problem and there is no control on the Adobe end of how to export this stuff. ( they are fields in filled out pdf forms where the data type were defined pretty haphazardly by someone who knew nothing about data and was just putting something up for manual entry - but I have a couple thousand records like this with 200 + fields I need to convert to VFP so I can then massage out child data and push data into an existing SQL database )

If I understand correctly, you're getting a CSV file that has legitimate CRLF character pairs to mark the proper ends of rows, but that also includes extra CRLFs in the middle of each row, which is causing problems with VFP's APPEND FROM etc.

If you already know how many columns you're supposed to be getting (say, N), you could extract N columns' worth of data at a time (based on the separating commas), and STRTRAN() or CHRTRAN() the extraneous CRLFs into some placeholder such as the "----" you suggest.

If you don't know how many columns you're getting (or you want to write something generic), you first need to figure that out. If there is at least one row that does not have any extraneous CRLFs, then the number of columns is the largest number of columns between successive CRLFs.

If every row has extraneous CRLFs, then you need some other consistent marker to delineate rows.

>Oh, secondary question - I forgot - what is the limit on the number of fields in a VFP DBF (assuming in DBC)

In VFP, "HELP System Capacities" at the command prompt gets you to this info.

255 assuming none allow .NULL., else 254. Maximum row size in a table is 65,500 characters.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Reply
Map
View

Click here to load this message in the networking platform