Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Import text data in vfp database

Import text data in vfp database

Import text data in vfp database

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???

RE: Import text data in vfp database

Hi superpruster,

1. If you have a carriage return at the end of each line, then you can use..

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

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

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

Hope this helps you

(Subramanian.G),FoxAcc, ramani_g@yahoo.com

RE: Import text data in vfp database

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

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

RE: Import text data in vfp database

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


RE: Import text data in vfp database


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

(Subramanian.G),FoxAcc, ramani_g@yahoo.com

RE: Import text data in vfp database

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.

RE: Import text data in vfp database

Great thank you this is what I needed!!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close