Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Splitting a card File so that it has a desired no of records

 Working directory /icmmfs/ACI_CMM/ACI01/ISS/CBEPD/files/app_files


 File to work with g046emdo*
 Before starting copy the files and work with the copied version so that the original is untouched
and is there for reference (e.g “cp g046emdo_000617 g046emdo_000617_new”)

1. Remove header & trailer by performing the below actions

 Open the working files (copied file) of g046emdo* (e.g g046emdo_000617_new )found in
/icmmfs/ACI_CMM/ACI01/ISS/CBEPD/files/app_files using ‘vi’ AIX command (e.g vi
g046emdo_000617_new)
 Then remove the header by double tapping the letter ‘d’ on the keyboard twice as if you are
double clicking on a mouse this is also an AIX command which deletes lines from a file
 Sample header is highlighted

 Do the same for the trailer, to go to the bottom which is where the trailer is at do ‘shift+g’ if the
file is large it may take a few minutes to get to the bottom when it does and you see the trailer
double tap the letter ‘d’ to remove the trailer.
 Sample trailer is highlighted
 After both header and trailer have been removed save the file by executing the AIX command
“ :wq “ and enter

2. Join the records in the file into a single record by using the below information

 Execute the following command on the files whose header and trailer have been removed
 sed 'N;s/\n//' input_file > output_file (e.g sed 'N;s/\n//' g046emdo_000617_new >
g046emdo_000617_join)
 To check if the command worked do wc –l command on the output file (wc –l
g046emdo_000617_join) whose count should be the count of the input files
(g046emdo_000617_new) divided by 2. To check the no of lines on the input file you can also do
the wc –l command (wc –l g046emdo_000617_new)

3. Then split the file into multiple files containing the desired amount of records the below is set up so
that the file is split into files containing 10,000 records each (the number can be less or greater than
10,000)

 split -l 10000 input file output file (to split into 5000 records “split -l 5000 input file output
file” ) e.g split -l 10000 g046emdo_000617_join g046emdo_000617_join
 input and output file names used for this step can be the same name
 The resulting files will have an extension added to them on top of the file name given as an
output (g046emdo_000617_joinaa, g046emdo_000617_joinab, g046emdo_000617_joinac…etc)

e.g

4. When this is done copy each file generated in step 3 by using winscp and add the header & trailer,
since the card sorting app need this information to sort

 You can copy the header and trailer from the original file (e.g g046emdo_000617) or you can
use any g046emdo_* file with smaller size if the original file is too big to open in notepad++, if
you do decide to use a different file then the original, one with smaller size then make sure to
edit the header date as well the one highlighted in the below image.
 when adding the header and trailer please do so from notepad++ and not from the server (like
by using AIX commands such as vi or more)
 Edit the trailer so that the count in the trailer matches the no of records on the file, so for a file
with records of 22500 the 1st two files will have a trailer of 10,000 and the third file will have a
trailer of 2500
 Also make sure the length of both the header and trailer are 2200

5. Copy the files with the header and trailer back to the server

6. To have all the records in a single line execute the below command, the file generated when
executing the command will be the final file that will be used as an input for the card splitting/sorting
tool

 tr -d '\n' < input_file > output_file


 e.g “ tr -d '\n' < g046emdo_000617_joinaa > g046emdo_000617_joinaa_final ”
 This should be done for all files generated as an output for step 4 (all g046emdo_000617_joina*
files with header and trailer added to them )

You might also like