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!

inserting blank record at interval

Status
Not open for further replies.

emboughey

Programmer
Mar 15, 2007
15
Hi,

I have a label format file that has the label set up with nothing in between for me to convert. I want to import into foxpro and insert a blank record after every 4th line.

Current format:

name
address
city state
zip
name
address
city state
zip
name
address
city state
zip

Format after:

name
address
city state
zip
(insert blank record)
name
address
city state
zip
(insert blank record)
name
address
city state
zip
(insert blank record)

Any help at all would be appreciated.
 
It appears as though you are using separate records for each separate field. That seems unusual. Typically you would use one record per label - each record with ALL fields. But perhaps you have your reasons.

You do not say how you are importing the records into the VFP table.
Are you using a single SQL Query, or scanning through records from another table - appending single records at a time, or what?

How you are doing the import may influence the suggestions we might offer.

Good Luck,
JRB-Bldr
 
I received the files in a pdf file and they were set up as label format. The problem is that when you convert from pdf to excel, it loses the line break between records.

What I ended up having to do was import the file delimited, put 2 pound signs when it encountered the zip code to signify end of record. (isdigit and len(field)) = 10)

After that I opened it in Microsoft word and did a search/replace to replace the 2 pound signs with a line break and then all of the paragraph marks with a comma.

I was just hoping for an easier way to do it.
 
So you are working in Excel and Word so far and have not put the data into a VFP table?

I'd suggest going directly from PDF to TXT and then doing an APPEND FROM <filename> DELIMITED or SDF into a table structure which matched your field requirements.

If I had to use Excel I would have done a Save As... --> DBF4.

Once I had the data into a VFP table I would then manipulate into a final format using a secondary query.

Good Luck,
JRB-Bldr
 
This code is crude and old, but I have been encountering this kind of file for years in the mailing industry and every time I use the code, it works fine. Some modification required. If you have a really large table, you might not want to use this code as its slow going record by record.

SELECT 1
USE text
** a file that has each line of address in each record after you import typ sdf
SELECT 2
USE LINE
**set up a one line dbf file any name will do
GO TOP
DO WHILE .NOT. EOF()
SELECT LINE
F1 = TRIM(LINE)
SKIP
F2 = TRIM(LINE)
SKIP
F3 = TRIM(LINE)
skip
F4 = TRIM(LINE)
SKIP
F5 = TRIM(LINE)
SKIP
f6 = trim(line)
SKIP

SELECT 1
APPEND BLANK
REPLACE L1 WITH F1
REPLACE L2 WITH F2
REPLACE L3 WITH F3
REPLACE L4 WITH F4
REPLACE L5 WITH F5
replace l6 with ' '
enddo
SKIP






 
Thank you. I actually am in the mailing industry as well so this is extremely helpful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top