RE: manipulating data files
Posted in 2000
Easy with shell script
cat src_file | while read LINE
do
F1=`echo $LINE | cut -c1-22`
F2=`echo $LINE | cut -c23-34`
F2=`echo $LINE | cut -c35-`
echo "$F1|$F2|F3" | tee dest_file.unl
done
do a man on cut to get more options
-----Original Message-----
From: triggerfish2001@hotmail.com [mailto:triggerfish2001@hotmail.com]
Sent: Thursday, 19 October, 2000 1:23 AM
To: informix-list@iiug.org
Subject: manipulating data files
Hi,
I have just basic knowledge of perl. The task I need to accomplish is as
follows:
source file needs to be converted to target file.
source file will be a fixed column length ASCII file of data.
target file will be a PIPE ('|') seperated ASCII file of data.
For eg:-
source file will be as follows:
John Smith 745-678-089011-10-1955
Robert IhaveAlongName345-567-453219-04-1967
Here the first 22 char is fixed length for name
Starting from 23rd char next 12 char is for SSN
Starting from 35th char next 10 char is for DOB.
Now this needs to be changed to
John Smith|745-678-0890|11-10-1955|
Robert IhaveAlongName|345-567-4532|19-04-1967|
The reason for this is that informix dbload or high performance loader needs
a field delimiter.
How can this be achieved in perl.
thanks.