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!

Import text data in vfp database 1

Status
Not open for further replies.

superprutser

Technical User
Nov 27, 2001
12
0
0
NL
I want to import a text file into a database. The text is not delimited.
Length of each line is 387 characters
The size of the complete textfile is 64.445.661 bytes
Each line has the same structure.

What is the solution for importing this file into a database???
 
Hi superpruster,

1. If you have a carriage return at the end of each line, then you can use..
=ALINES(myArray,FILETOSTR(myTextFile))

2. If however, this is not having the carriage return every 387 characters (your record length).. then..

myText = FILETOSTR(myTextFile)
myTotLines = LEN(myText)/387

x=1
FOR x=1 to myTotLines
i=1+((x-1)*387)
myEachLine = SUBSTR(myText,i,387)
** Store or further strip and updte your table
ENDFOR

Hope this helps you :) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
If I understand your question correctly, each row of data is a record and each field is a fixed length in the row. If this is true, then look at option of SDF from the append from command

USE mytable
APPEND FROM mytext TYPE SDF

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.
Attitude is Everything
 
I have tried to import the file with alines......
that works until a box appears with the text SUBSCRIPT IS OUTSIDE DEFINED RANGE.
Again I have a problem.........

The total size of the text file is 64.445.661 bytes
The first line (Header) contains 84 characters
The other lines (Detail) contains 387 characters each
The last line (Trailer) contains 7 characters

Total lines to import 195145

WHAT DO I HAVE TO DO TO IMPORT THIS FILE COMPLETELY INTO A DATABASE???????
 
HI

1. Create a table with the appropriate file structure.(New table created using VFP)
2. Now use the VFP editor to open the text file.
MODI FILE myFile.txt
Delete the first line, and Delete the last trailer line.
SAVE AS a myFile1.txt
3. Now.. Open the file created in step 1 with command
USE myTable
and append.. using code..
APPEND FROM myFile1.txt SDF

Hope this solves your problem :) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
If Ramani's suggestion doesn't solve your problem, please post a section of your file, including the First Line, several of the middle lines, and the Last Line.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top