I think the following is a common practice for .CSV Comma Seperated Volume files. At least it seems to be how Excel interprets imported .CSV files.
Some fields are delimited/enclosed with "Double-Quotation-Marks" on each end. This happens if the following characters are necessary to be used within a field.
1) "Single-Quotation-Mark"
2) "Double-Quotation-MarK
3) an actual "Comma"
Since we've had problems with VFP-7's Wizards importing these .CSV files converted by Excel, I've written a VFP program that uses Low-level VFP Functions.
1) Prompt the user for Header lines and which line to start the data import from. If it has a Header-Row, you can get the exact number of fields each data row should have using:
lnField_Count = OCCURS(lcField_Delim, lcField_List)
2) I get the Maximum field widths for "N" number of rows or check widths for all Data Rows.
3) Loop the data rows using:
lcText = ALLTRIM(FGETS(lnINPUTHandle, lnBytes))
Which Reads bytes until CHR(13), the end of line CR character is encountered.
Here is the parseing logic for each extracted line of data:
Double-Quotation-Mark OR the user selected, Field-Delimiter-Mark is encountered, then...
Skip any subsequent delimiters until an even number of Double-Quotation-Marks have been passed over. Thereafter, the NEXT delimiter is the actual position of the end of that field.
Unless another Double-Quotation-Mark is found first. Then continue to keep skipping subsequent delimiters.
4) Next I load a Grid control to present a possible VFP .DBF file structure, for the user to alter as needed for Field Widths and Data Types.
5) Then I load the Grid on the Preview-Tab with a sample of the data.
This is my WIP, a Quick 3-tabbed pageframe on a VFP Form. Should be much simpler, faster, and work correctly. This is actually easier then editing the VFP Import Wizard and has a more efficient visual interface, with more modern coding methods then the Ancient VFP Import Wizard Code.