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

Compress data in comma delimited file

Status
Not open for further replies.

bhl

IS-IT--Management
Aug 22, 2001
27
US
I created a comma delimited file by just setting up the record with comma fields. It has fixed length records in it but since each field is fixed there is a lot of free space at the end of each field. Is there a way I can compress the data in the fields to get rid of the blank space at the end of each field.

This is run on Microfocus COBOL.

Thanks

Bruce

Following is the record layout.

Select KO-Purge1-in-file
Assign to "d:\btftp\bookpgms\purge1.txt"
organization is line sequential.

FD KO-Purge1-in-file.
01 KO-Purge1-record.
05 KO-Purge1-seller-prefix pic X(3) value "CDB".
05 KO-Purge1-seller-number pic 9(8) value zeros.
05 comma-1 pic X value ",".
05 KO-Purge1-author pic X(50) value spaces.
05 comma-2 pic X value ",".
05 KO-Purge1-title pic X(50) value spaces.
05 comma-3 pic X value ",".
05 KO-Purge1-illustrator pic X(25) value spaces.
05 comma-4 pic X value ",".
05 KO-Purge1-book-condition pic X(5) value spaces.
05 comma-5 pic X value ",".
05 KO-Purge1-book-size pic X(5) value spaces.
05 comma-6 pic X value ",".
05 KO-Purge1-jacket-condition pic X(5) value spaces.
05 comma-7 pic X value ",".
05 KO-Purge1-binding pic X(50).
05 comma-8 pic X value ",".
05 KO-Purge1-book-type pic X(5) value spaces.
05 comma-9 pic X value ",".
05 KO-Purge1-ISBN pic X(13) value spaces.
05 comma-10 pic X value ",".
05 KO-Purge1-publisher pic X(50) value spaces.
05 comma-11 pic X value ",".
05 KO-Purge1-publish-place pic X(5) value spaces.
05 comma-12 pic X value ",".
05 KO-Purge1-publish-date pic X(7) value spaces.
05 comma-13 pic X value ",".
05 KO-Purge1-edition pic X(5) value spaces.
05 comma-14 pic X value ",".
05 KO-Purge1-inscription pic X(5) value spaces.
05 comma-15 pic X Value ",".
05 KO-Purge1-description pic X(300) value spaces.
05 comma-16 pic X value ",".
05 KO-Purge1-quantity pic ZZZZZ value spaces.
05 comma-17 pic X value ",".
05 KO-Purge1-price pic ZZZZZ.99 value zeros.
05 comma-18 pic X value ",".
05 KO-Purge1-image pic X(5) value spaces.
05 comma-19 pic X value ",".
05 KO-Purge1-category pic X(128) value spaces.
05 comma-20 pic X value ",".
05 KO-Purge1-c2 pic X(5) value spaces.
05 comma-21 pic X value ",".
05 KO-Purge1-c3 pic X(5) value spaces.
05 comma-22 pic X value ",".
05 KO-Purge1-c4 pic X(5) value spaces.
05 comma-23 pic X value ",".
05 KO-Purge1-c5 pic X(5) value spaces.
05 comma-24 pic X value ",".
05 KO-Purge1-kwd1 pic X(5) value spaces.
05 comma-25 pic X value ",".
05 KO-Purge1-kwd2 pic X(5) value spaces.
05 comma-26 pic X value ",".
05 KO-Purge1-kwd3 pic X(5) value spaces.
05 comma-27 pic X value ",".
05 KO-Purge1-kwd4 pic X(5) value spaces.
05 comma-28 pic X value ",".
05 KO-Purge1-kwd5 pic X(5) value spaces.
05 comma-29 pic X value ",".
05 KO-Purge1-kwd6 pic X(5) value spaces.
05 comma-30 pic X value ",".
05 KO-Purge1-kwd7 pic X(5) value spaces.
05 comma-31 pic X value ",".
05 KO-Purge1-kwd8 pic X(5) value spaces.
05 comma-32 pic X value ",".
05 KO-Purge1-kwd9 pic X(5) value spaces.
 
Use a combination of a function to get the size of each individual string and tht string command.

E.g. For each field.

1-get size of field
2-string field into working-record using pointer

INSPECT FUNCTION REVERSE( KO-Purge1-author )
TALLYING spaces-count FOR LEADING SPACES.

string ","
KO-Purge1-author(1:field-size - spaces-count) delimited by size
into w01-work-size
pointer w01-pointer

This for every field except the first one where you remove the "," bit

Be sure to initialize the variable "w01-pointer" to 1 before starting processing each record, and spaces-count to 0 before each individual field.



Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top