Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Append From File Question

Status
Not open for further replies.

sasa888

Programmer
Oct 15, 2001
131
0
0
US
Hi all, I am new to Visual FoxPro and I am reviewing someone's code right now. My issue is, I saw the following code and not quite sure if this is the piece to import data into a VFP table. Given the &gcDirFileName is the directory path where the text file located, does it mean the following code read line by line from the text file and import into the LdCont table? If so, how does the program know if it is delimited or another format? Please help!!


Select LdCont
use
use ldcont exclu
Append From &gcDirFileName TYPE SDF
GOTO TOP
BROWSE
pack
 
gcDirFileName is a variable

The variable contains a text string representing a fully pathed file name - assumed to be a text file.

The APPEND FROM command will add the contents of the text file into the VFP data table ldcont

Yes each text line will become a new record in the data table.

The SDF option on the command tells the command to anticipate the data to arrive in a standardized format (hence using the option - Standardized Data Format)

Good Luck,
JRB-Bldr


 
TIP: If you want to know what that SDF file looks like, use ldcont yourself, and do a [copy to ... sdf] and look at the contents.

B-)

Good luck




Regards

Griff
Keep [Smile]ing
 
Hi Sasa888,

Welcome to Visual FoxPro. Just to amplify Select LdCont JRB-Bldr's reply:

[blue]Select LdCont[/blue] Makes a table named ldCont the "current" table

[blue]use[/blue] Closes the current table

[blue]use ldcont exclu[/blue] Re-opens that same table; opens it for exclusive use (other users cannot access it)

[blue]Append From &gcDirFileName TYPE SDF[/blue] Copies data from a text file, the name of which is held in a variable named gcDirFielName

[blue]GOTO TOP[/blue] Goes to the first record in LdCont (the very first record in the table, not necessarily the first of the copied records).

[blue]BROWSE[/blue] Opens the table in a browse window

[blue]pack[/blue] Removes any deleted records from the table

The SDF in the APPEND command stands for System Data Format (not Standardized Data Format as JRB-Bldr suggested, but it doesn't really matter as everyone just uses the initials). Essentially, SDF means that each field in the text file occupies a fixed width, without any delimiters. FoxPro uses the field widths within the target table to determine where each field begins and ends.

Hope this is useful.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike - not to be a nit-picker, but just to make certain that I have not been telling in-accuracies to people for years...

The VFP Help file does indeed define SDF with the phrase "System Data Format". (I have to admit that I didn't think to look there before now.)

However since SDF has meaning outside the VFP world especially when related to Importing and Exporting files, I went to the web to look for an industry-wide definition for SDF I find a variety of phrases (generally all meaning the same thing).

SDF Standard Data Format
SDF System Data Format
SDF Structured Data Format
SDF Simple Data Format

There were numerous others as well but those are the most prevalent ones relating to file formats.

Hey there was even
SDF Scottish Drug Forum

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top