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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Append from Fixed Width Text File 2

Status
Not open for further replies.

Concentra2007

Technical User
Jul 19, 2007
9
US
Hello Experts,
From this site, I've learned that to import a tab delimited text file in a FoxPro program, a workable command is

APPEND FROM 'rdid16.txt' delimited with tab

What is the proper command for a fixed width text file?

I know this is an easy question, but I've been searching forum questions and FAQs for over an hour. I'm guessing one of you could answer in about 5 seconds.

Thanks!!!
 
Try
Append from database sdf
wjwjr

This old world keeps spinning round - It's a wonder tall trees ain't layin' down
 
1. Create a cursor with as many fields as you have in Text file.
2. These fields must be with the same length as the fields in the text file.
3. Then just use APPEND FROM TextFile.TXT SDF

Code:
TEXT TO lcExample NOSHOW PRETEXT 7
     1234aaaaaaaaaa1234567890
     1234aaaaaaaaaa1234567890
     1234aaaaaaaaaa1234567890
     1234aaaaaaaaaa1234567890
     1234aaaaaaaaaa1234567890
ENDTEXT
STRTOFILE(lcExample,[c:\test.txt])
CREATE CURSOR crsAppendTest (Fld1 N(4), Fld2 C(10), Fld3 N(10))
APPEND FROM c:\test.txt SDF
BROWSE NORMAL

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
why don't you take a look in the help on the APPEND FROM command? Of course you need to know that SDF stands for such a format, but the help explains every supported format:

SDF

Include SDF to import data from a System Data Format file. An SDF file is an ASCII text file in which records have a fixed length and end with a carriage return and line feed. Fields are not delimited. The file name extension is assumed to be .txt for SDF files.

Effective conversion of date data from SDF files to Visual FoxPro tables requires data to be stored in YYYYMMDD format.

If date information is stored in ambiguous formats, you should map the date column to a character column of appropriate width so you can inspect the value and then apply the correct conversion routine to create correctly formatted date data.

Bye, Olaf.
 
Hello All - sdf worked great; Thank you!! It took me a few tries to get all the column lengths correctly, but this was the answer.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top