07-26-2004
Filling in characters to line a file up
Hi there, Ive got a feeling this is quite complex but I have a Comma delimited file which is being transfered up to a mainframe and I have to get every column lining up , I need to add in characters to line it up (but different characters and in different positions based on what field/column it is.
For example here is my original file ......
12345,abcdef,123456789,abcd
123456,abcdef,1234567,abcd
and here is what i need doing ............
1) IF data in field 1 is less than 6 characters long then put enough spaces after the last character to make it up to 6
2) Fields 2 and 4 are fixed at 7 characters and will always be populated by 7 character data
3) IF data in Field 3 is less than 10 characters then place leading zero's in front until 10 characters long
So the end result will look like this...
12345 ,abcdef,0123456789,abcd
123456,abcdef,0001234567,abcd
all lined up lovely for processing
If anybody could give me a few tips on what i would need to do to get started on this and what programs i need to use etc then that would be fantastic
cheers
Gary
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi all,
I have a file with multiple lines. I want to replace characters 7 through 14 of every line with 0000000
Input:
12345678901234567890
23456789012345678901
Output
12345600000004567890
23456700000005678901
Please help.
JaK (9 Replies)
Discussion started by: jakSun8
9 Replies
2. Shell Programming and Scripting
Hello, Member or professional
need help how to count characters by line of file
Example of the file is here
cdr20080817164322811681txt
cdr20080817164322811txt
cdr20080817164322811683txt
cdr20080817164322811684txt
I want to count the characters by line of file . The output that I... (4 Replies)
Discussion started by: ooilinlove
4 Replies
3. Shell Programming and Scripting
Hi Friends
I have a file
like
sample1.txt
------------
10998909.txt
10898990.txt
1898772222.txt
8980000000000.txt
I need to take first 3 characters of each line in a file and i need to print it '
like loop
109
108
189
898 (7 Replies)
Discussion started by: kittusri9
7 Replies
4. UNIX for Dummies Questions & Answers
Dear Members,
For example i have a file which contains 10 lines as below:
123testing
gopjp
jg9459\
834789rh
fh456
47rf
497rvg
409748\
08ntr
i need the first three characters of the first line of the file.
if i use
cut -c 1-3 < sample.txtits displaying the 1st three... (8 Replies)
Discussion started by: sandeep_1105
8 Replies
5. Shell Programming and Scripting
Hi,
I have a file with about 25 colums separated with '~', but few of the lines have extra tabs ('^') and new line characters ('$'). Is there a way I can delete those characters if they are anywhere before the 25th column in a line?
example:
CLUB000650;12345678;0087788667;NOOP MEMBER ... (4 Replies)
Discussion started by: rudoraj
4 Replies
6. Shell Programming and Scripting
I am having a file(1234.txt) downloaded from windows server (in Ascii format).However when i ftp this file to Unix server and try to work with it..i am unable to do anything.When i try to open the file using vi editor the file opens in the following format ...
@
@
@
@
@
@
@
@... (4 Replies)
Discussion started by: appu2176
4 Replies
7. Shell Programming and Scripting
Hi Everyone,
i have a file 1.txt
<a><a"" dd>aaaaauweopriuew</f><">!(^)!</aa></ff>
<a><a"" dd>bbbbbuweopriuew</f><">!(^*)!</aa></ff>
i know i can use
perl -p -i -e "s/>aaaaa/aa/g" 1.txt
perl -p -i -e "s/>bbbbb/bb/g" 1.txt
to acheive only keep the first two characters of the five characters,... (4 Replies)
Discussion started by: jimmy_y
4 Replies
8. Shell Programming and Scripting
I have this command that i am calling from php (exec()):
openssl pkcs12 -export -in cert.pem -inkey key.pem -out cred.p12
and then i need to insert password twice
Enter Export Password:
Verifying - Enter Export Password:
I need script that will fill the password... (3 Replies)
Discussion started by: rockyada
3 Replies
9. Shell Programming and Scripting
Hi All,
I need to find new line characters in a file and their location in the file and print the results. can someone pleas help.
KM (4 Replies)
Discussion started by: Kevin Tivoli
4 Replies
10. Shell Programming and Scripting
Hello,
I would like to copy the first and third char on each line of a file and place them in the 14h and 17th char positions. The file name is listed first and is 6 char's and the dir name is second and also same char size on each line.
The file has thousands of lines.
Initial... (6 Replies)
Discussion started by: dmm
6 Replies
LEARN ABOUT DEBIAN
gd::barcode::upce
Barcode::UPCE(3pm) User Contributed Perl Documentation Barcode::UPCE(3pm)
NAME
GD::Barcode::UPCE - Create UPC-E barcode image with GD
SYNOPSIS
ex. CGI
use GD::Barcode::UPCE;
binmode(STDOUT);
print "Content-Type: image/png
";
print GD::Barcode::UPCE->new('123456')->plot->png;
with Error Check
my $oGdBar = GD::Barcode::UPCE->new('123456789');
die $GD::Barcode::UPCE::errStr unless($oGdBar); #Invalid Length
DESCRIPTION
GD::Barcode::UPCE is a subclass of GD::Barcode and allows you to create UPC-E barcode image with GD. This module based on "Generate
Barcode Ver 1.02 By Shisei Hanai 97/08/22".
new
$oGdBar = GD::Barcode::UPCE->new($sTxt);
Constructor. Creates a GD::Barcode::UPCE object for $sTxt. $sTxt has 6 or 7 or 8 numeric characters([0-9]). If $sTxt has 6 characters,
this module adds '0' at the front of $sTxt. and calculates CD for you. If $sTxt has 7 characters, this module calaculates CD for you.
plot()
$oGd = $oGdBar->plot([Height => $iHeight, NoText => 0 | 1]);
creates GD object with barcode image for the $sTxt specified at new method. $iHeight is height of the image. If NoText is 1, the image has
no text image of $sTxt.
ex.
my $oGdB = GD::Barcode::UPCE->new('123456');
my $oGD = $oGdB->plot(NoText=>1, Height => 20);
# $sGD is a GD image with Height=>20 pixels, with no text.
barcode()
$sPtn = $oGdBar->barcode();
returns a barcode pattern in string with '1', 'G' and '0'. '1' means black, 'G' also means black but little bit long, '0' means white.
ex.
my $oGdB = GD::Barcode::UPCE->new('123456');
my $sPtn = $oGdB->barcode();
# $sPtn = '';
$errStr
$GD::Barcode::UPCE::errStr
has error message.
$text
$oGdBar->{$text}
has barcode text based on $sTxt specified in new method.
AUTHOR
Kawai Takanori GCD00051@nifty.ne.jp
COPYRIGHT
The GD::Barocde::UPCE module is Copyright (c) 2000 Kawai Takanori. Japan. All rights reserved.
You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.
SEE ALSO
GD::Barcode
perl v5.12.3 2003-05-29 Barcode::UPCE(3pm)