General discussion

Locked

Converting Web file to usable format.

By paul ·
Is there anyone out there that can tell me how to change a text file that has keycodes next to the lines (ie - NM Paul Donovan) NM is the keycode for name and the name follows after the space. there could be 1-10 names and then the next coded lines are co for company, ad for address, city st, and em for email. it is in a label format. Hard to derive. I'm thinking of using foxpro and doing a line by line read. Also the first line of each record is the record number.

Please email me at paul@websterprinting.com if you have an answer.

Thanks,

paul

This conversation is currently closed to new comments.

10 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Converting Web file to usable format.

by Bob Sellman In reply to Converting Web file to us ...

I'll give you an idea of how you can do it using Access. The concept should be similar for Foxpro or another DB.

I'm going to assume that you want to take each record's information in the text file and place it into a record in a table in your database.

I'm also going to assume that the text file will look something like this:

1 2 3
nm Max Joe Sally
ad Here There Everythere

One important point is that (I'm assuming) the start of every different name, address, company, city, etc. starts at the same character position in each line.

First, import the text file into a table (I'll call it TextTable) that has only one (text) field, long enough to hold each line of the text file.

Next you have to write some code (VBA with Access or something similar with FoxPro) that will go though all of the records in TextTable one at a time (in the order they were imported).

Set up some variables (or a recordset) to hold the name, address,company, etc., data for each record. You must have enough variables to hold the number of records that one line of the text file holds. So if you use a separate variable for each item and the text file was for 3 across mailing labels, so might have name1, name2, and name3 (and so on).

You look for the following:
1. What code are the first two letters that indicate whether it's names, city, company, etc.

2. Extract (mid$(textstring,startloc,length)) the text for each of the label positions, making the appropriate variable (or field in the recordset) equal to the text extracted. For example: name1 = mid$(textstring,4,10), name2 = mid$(textstring,18,10) and so on.

Once you complete one full set across of mailing labels, append them values to the appropriate number of records (3 if the mailing labels are 3 across) to your destination table.

Collapse -

Converting Web file to usable format.

by paul In reply to Converting Web file to us ...

After I recieved this answer, he showed me how to successfully extract the data.

Thanks Bob!

paul

Collapse -

Converting Web file to usable format.

by RiverNet In reply to Converting Web file to us ...

Hi, Paul,


I can't add anything to Bob's excellent suggestion except that if you don't care to do the work yourself, I can offer to create a small VB utility that you can use for the conversion. I have done many such conversions and would only need for you to email me a representative sample of your records (or if you'd rather not release your data, some fake examples).

Collapse -

Converting Web file to usable format.

by paul In reply to Converting Web file to us ...

Poster rated this answer

Collapse -

Converting Web file to usable format.

by paul In reply to Converting Web file to us ...

Point value changed by question poster.

Collapse -

Converting Web file to usable format.

by tjc In reply to Converting Web file to us ...

So how did it go. If you figured it please close this, else post an update on your progress. I see that the above looks good on what to do and I really can't add anything new.

Collapse -

Converting Web file to usable format.

by paul In reply to Converting Web file to us ...

Poster rated this answer

Collapse -

Converting Web file to usable format.

by Cedric King In reply to Converting Web file to us ...

I agree with the answers provided. If you want, I can offer to write some ASP codes to do all that too. :)

Collapse -

Converting Web file to usable format.

by paul In reply to Converting Web file to us ...

Poster rated this answer

Collapse -

Converting Web file to usable format.

by paul In reply to Converting Web file to us ...

This question was closed by the author

Back to Web Development Forum
10 total posts (Page 1 of 1)  

Software Forums