Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Importing from a line delimited text file
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00094304
Message ID:
00094329
Views:
25
>>>I have a table with about 40 fields and I am wanting to write a program to import a text file into this table. The way I envision doing this is with 40 fgets() into 40 variables and then do an insert into with the 40 variables. Is the best way to accomplish this task?
>>
>>I don't think so...I did it that way years ago, but now I use a dbf structure with Append From flatfile Type SDF.
>
>More on this...here's the idea I used:
>
>1) Append all lines into a table T1
>2) Create T2, with 40 fields or whatever
>3) Create AFIELDS(A1,'T2')
>4) Go through loop, using Replace (A1,ncounter,1) with T1 value (SKIP each time) for each grouping of 40 or whatever T1 records, 1 to ncounter. Do APPEND BLANK each time for T2.
>5) Reformat any non-char fields afterwards. If you do this regularly, create a program to do it...

I do something similar

Append into table T1 (if there are more fields than I require, I make sure that the fields I need have the same name in T1 as the permanent table)

Then if reformating is required, create a SQL statement into table T2
Then append into permanent table
"You don't manage people. You manage things - people you lead" Adm. Grace Hopper
Pflugerville, between a Rock and a Weird Place
Previous
Reply
Map
View

Click here to load this message in the networking platform