Hi Waldo,
To best answer this question, itâs worth taking a simple step backwards.
The dictionary is no more than a repository where you declare file structures.
the templates use the dictionary as input in a variety of places.
But that does not mean you are limited by the dictionary, or the templates. You are very able to declare a table structure (FILE) as a local data structure in any procedure, by hand. So itâs completely possible to declare a local structure, based on say the ASCII, BASIC or DOS drivers, and then code a CSV import from there. No dictionary, or template, required.
If you do want to use a template, then you get to declare the structure in the dictionary, simply because that is where the templates get their structures from. The one is input to the other.
Of course declaring specific FILE structures for each CSV you might want to import seems like a lot of work. In that case you can treat the FILE as a âblock of textâ and then simply parse that block using the Clarion String Handling functions (Instring, sub etc.) Using this approach you can re-use a single structure all over the place with minimal effort.
Of course the DOS driver requires the file to be loaded in blocks, and then stitch the blocks together before (or during) parsing. By contrast the Windows API allows you to read the whole file into a single string with minimal code. This is a bit faster, and removes the need to parse rows that span across blocks. BUT limits the size of CSV you can import (probably something around a gig in size becomes the practical maximum.)
If you do this approach a couple times you will eventually make your own higher=level string functions to make things easier. You can build these directly on the Clarion string commands, or the SystemString class.
Because I do this sort of work a lot, and because we deal with even more complicated CSV formats (EDI, HL7 etc), I maintain a string library to do all this work for me. So doing these imports typically takes no more than a handful of lines, plus one line per field. The string library I maintain is called StringTheory (the one Jeff linked to above). Itâs the premier string handling library used by most Clarion programmers to do, well, pretty much everything string related.
So the good news is, you have lots of choices and approaches you can take. Which one you prefer will depend on your requirements and also your willingness to write code, or use code written by others.
Cheers
Bruce