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!

Text File woes continues 1

Status
Not open for further replies.

DocBus

IS-IT--Management
May 26, 2005
13
NL
Thanks to all who have helped in my previous question - that solved the problem instantly - the problem was here
I have a tabel structure created from various (100+) delimited files. I know this is not ideal but I have to work with what I have, cannot use type csv. The files are delimeted with TABS "chr(9)". When I use the following code two things happen:

Code:
 Append from log.txt Delimited with Tab

1. The table structure I automatically created has truncated fieldnames (max 10characters). The text file to be imported's fields are delimited in the same order as the table. However, the append command does not place it in the right order in the table, i.e. patcode is placed at mycode (names for illustration).

2. I also notice that the browse view is not ordered in the same way as the table structure, does this matter?

Any ideas appreciated!!!!
 

DocBus,

Are you talking about the order of fields or the order of records?

The order of records that you are seeing in a browse window is affected by the controlling index. If you execute SET ORDER TO in the command window before the browse, you should see the records in the same order as in the text file.

The order of fields should follow the same order as the text file. I can't see how you can change that even if you wanted to. After all, the text file doesn't know the field names; it simply presents the data to the DBF in the order it finds it.

Again, it's possible that the browse window is not showing the real situation -- possibly because you are doing a BROWSE LAST. Try closing the table and re-opening it, then doing BROWSE (not BROWSE LAST) from the command window.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Thanks Mike,

The problem is the order the of the fields getting import into the record is wrong. I.e. in the file structure the fields are listed as follows - my_code, code, date, decis

The text file follows the same structure. However when it is imported with append to the date field gets imported from the text file to the code field etc.

The first line of the text file looks something like this
Code:
12344 <tab> 3456 <tab> 10/09/2005 <tab> 1,3,5,6,8,message,blue <tab> etc etc with delimited with tabs CR

I use browse to test the table that is created but will not do it at runtime. I am writing this routine to import stacks of medical data that I need to analyze. Unfortunately the application that provides the data does not deliver a constant file. :-(

Thanks for your help!!!!

Cobus van Wyk
 
BTW,

The Foxpro Import Wizard does a great job with importing files. However - there is very little in the code section to suggest doing the same thing at runtime, automatically. Does anyone know where the code for the VFP import wizard stands? I ask this as a newbie in this regards - maybe I can learn a bit from that!

Once again thanks for any help!!!1

Cobus van Wyk
 
My two cents:
The problem is the order the of the fields getting import into the record is wrong.

The fields will get imported into the table you create, in the order the fields are created or listed in the MODIFY STRUCTURE dialog. Fox won't just shuffle them at will.
It is possible however, that there is more than one tab between fields. That could put them in the wrong place.

But one way or the other, you will have to determine the layout/field order of every file you plan on importing and have a unique table structure for each, unles you write some sort of complex parsing routine.

-Dave Summers-
[cheers]
Even more Fox stuff at:
 

Cobus,

One other slight possibility: You have a SET FIELDS statement in force. But that's not very likely. More probable that you have an extra tab somewhere, as Dave suggested.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top