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

Import CSV to DBF

Status
Not open for further replies.

bobtwigg

Technical User
Nov 2, 2002
6
0
0
US
I have a databse application someone wrote using Delphi 1. They used Alpha 5, Version 1 to load data exported from another system. The input is a .CSV file and A5V1 imports it into the file replacing the previous records, and then recreates the index .MDX file. I need to move this application to a new system. We can not find A5V1 and A5V3 makes .DBF files we can't use with a Delphi 1 app. We can not conver the the Delphi 1 project to Delphi 3 which we have. Is there a utility we can use to map the fields and import the .CSV file data into the dBase .DBF and .MDX files? I only do AS/400 programming so I am at a loss here.
 
Create the table (.dbf) in dBase (assuming you have this since you asked about converting to it), using the field names from the first line in the CSV file. Then in dBase (or FoxPro or any other platform to which you can apply the xBase language) execute the commands :

USE [tablename}
APPEND FROM [filename]TYPE CVS

This will add all the records from your CSV file to the file[tablename].dbf. Indexes would have to be created separately, I believe. I'm not experienced with either Delphi or Alpha5, so folks with more background in those proeducts may know of another way to create the dBase indexes. Otherwise, I would guess you would have to have knowledge of the index file names and key fields.
 
1oldfoxman is correct - you'll have to create new indexes for the files, which should take less than a minute. (It's never a good idea to trust imported index files anyway. Always reindex the file or create new indexes.) There's always a better way...
 
Unfortunately I do not have dBase. The file was originally created by Alpha 5 Version 1, which I do not have either.
 
So, let me try to understand what you are really trying to do.
1. You need to continue to read a CSV file into an existing Alpha5 v1 data table with Alpha5 v1 indexes? (the .MDX file I'm not familiar with, so I'm assuming it is a proprietary Alpha5 format. dBase index files have the extension .NDX or .IDX)

2. For whatever reason, you are unable to move existing Alpha5 v1 program, data files, indexes directly to whatever new system you need to migrate to? (Is this because of operating sytems issues, hardware issues, or??????) It seems like the easiest thing to do is move the whole set of files/applications to the new system. Are you unable to locate the orginal Alpha5 executables that moved the data?

 
Is it possible to send me sample copies (perferrably old ones) of both the CSV and DBF files? A visual inspection may help.

--MiggyD
miggyd2000@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top