Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
IMPORT DELIMITED FILES
Message
From
25/01/2000 04:03:17
 
 
To
25/01/2000 03:21:01
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00322061
Message ID:
00322065
Views:
20
>HOW CAN I IMPORT DELIMITED FILES INTO TABLE IN VFP V5?
>
>I now try to using append command to import the file. But problem is I need to creat a temp table 1st. But how can I select unique file name and how to do with it after finish using temp file. Delete it?
>

You can generate a single temporary file name usig the SYS(3) function. It's right in the on-line help. Once you save the name of the temporary file to a memory variable you can consistently reference that file using the name you've saved.

You'll need to create a table with the necessary structure that matches the format of the input file. CREATE TABLE will do this programmatically. You need to know what the layout of the temporary file is so that you can assign appropriate field names, types and sizes. CREATE TABLE is in the on-line docs.

An alternative to CREATE TABLE is to use CREATE CURSOR - it creates a temporary .DBF in the same way that CREATE TABLE would make a permanent table - the difference is that you only really know the alias used to reference the cursor, since a unique file name is generated each time you issue CREATE CURSOR, and the cursor ceases to exist if you close it at any time.

Once you've created a temporary table with the necessary structure that matches the format of the delimited file (I'm assuming since you've given no information on this that it is a standard comma-delimited text file) that you would then use the APPEND FROM filename TYPE DELIMITED command to add that data to the temporary table. The APPEND FROM command is right in the on-line help file.

You can then do whatever is needed with the temporary table. Again, not knowing anything about what you're doing, it's assumed that you have some plan of action to add the records in the temporary table to the main data file.

Once you're done with the temporary table, you can dispose of it as required. If it is a cursor, the act of closing the cursor via the USE command will delete the file automatically. If you've used CREATE TABLE, the ERASE command can be used to delete a file from the disk. And, as usual, the command is in the on-line documentation.

>Can anyone suggest me the best way to import delimited file.

There unfortunately is no single best way, and if the file format is inconsistent, or cannot be matched to the native APPEND command syntax, you may have to use the low-level file I/O commands to read and parse the data.

>
>Thank u.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform