RE: [RMX:#] Re: [RMX:#] Re: [RMX:#] Re: [RMX:#] Re: How to compar

RE: [RMX:#] Re: [RMX:#] Re: [RMX:#] Re: [RMX:#] Re: How to compar

am 27.02.2007 09:34:15 von Reddy.Beri-Veera-ext

Hi,
Sorry for trouble.
Input file:
##############################
CADItem;56500000001295;A4;IMAN_specification;TIFFDrawing;565 00000001295_dr01
;tif;56500000001295_dr01.tif
CADItem;56500000001295;A4;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
images_preview.qaf
CADItem;56500000001295;A4;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
qafmetadata.qaf
CADItem;56500000001295;A4;IMAN_specification;UGMASTER;565000 00001295-A1;prt;
56500000059898_A1.prt
CADItem;56500000001295;A4;IMAN_specification;UGPART;56500000 001295_dr01;qaf;
dwg_sht1.qaf
CADItem;56500000001295;A4;IMAN_specification;UGPART;56500000 001295_dr01;qaf;
qafmetadata.qaf
CADItem;56500000001295;A4;IMAN_specification;UGPART;56500000 001295_dr01;prt;
56500000001295_dr01.prt
CADItem;56500000001295;A2;IMAN_specification;TIFFDrawing;565 00000001295_dr01
;tif;56500000001295_dr01.tif
CADItem;56500000001295;A2;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
images_preview.qaf
CADItem;56500000001295;A2;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
qafmetadata.qaf
CADItem;56500000001295;A2;IMAN_specification;UGMASTER;565000 00001295-A1;prt;
56500000059898_A1.prt
CADItem;56500000001295;A2;IMAN_specification;UGPART;56500000 001295_dr01;qaf;
dwg_sht1.qaf
CADItem;56500000001295;A2;IMAN_specification;UGPART;56500000 001295_dr01;qaf;
qafmetadata.qaf
CADItem;56500000001295;A2;IMAN_specification;UGPART;56500000 001295_dr01;prt;
56500000001295_dr01.prt
CADItem;56500000001295;A5;IMAN_specification;TIFFDrawing;565 00000001295_dr01
;tif;56500000001295_dr01.tif
CADItem;56500000001295;A5;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
images_preview.qaf
CADItem;56500000001295;A5;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
qafmetadata.qaf
CADItem;56500000001295;A5;IMAN_specification;UGMASTER;565000 00001295-A1;prt;
56500000059898_A1.prt
CADItem;56500000001295;A5;IMAN_specification;UGPART;56500000 001295_dr01;qaf;
dwg_sht1.qaf
CADItem;56500000001295;A5;IMAN_specification;UGPART;56500000 001295_dr01;qaf;
qafmetadata.qaf
CADItem;56500000001295;A5;IMAN_specification;UGPART;56500000 001295_dr01;prt;
56500000001295_dr01.prt
CADItem;56500000001295;A3;IMAN_specification;TIFFDrawing;565 00000001295_dr01
;tif;56500000001295_dr01.tif
CADItem;56500000001295;A3;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
images_preview.qaf
CADItem;56500000001295;A3;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
qafmetadata.qaf
CADItem;56500000001295;A3;IMAN_specification;UGMASTER;565000 00001295-A1;prt;
56500000059898_A1.prt
CADItem;56500000001295;A3;IMAN_specification;UGPART;56500000 001295_dr01;qaf;
dwg_sht1.qaf
CADItem;56500000001295;A3;IMAN_specification;UGPART;56500000 001295_dr01;qaf;
qafmetadata.qaf
CADItem;56500000001295;A3;IMAN_specification;UGPART;56500000 001295_dr01;prt;
56500000001295_dr01.prt
CADItem;56500000001295;A1;previous_TIFF;TIFFDrawing;56500000 001295_dr01;tif;
56500000001295_dr01.tif
CADItem;56500000001295;A1;IMAN_specification;TIFFDrawing;565 00000001295_dr01
;tif;56500000001295_dr01.tif
CADItem;56500000001295;A1;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
images_preview.qaf
CADItem;56500000001295;A1;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
qafmetadata.qaf
CADItem;56500000001295;A1;IMAN_specification;UGMASTER;565000 00001295-A1;prt;
56500000059898_A1.prt
CADItem;56500000001295;A1;IMAN_specification;UGPART;56500000 001295_dr01;qaf;
dwg_sht1.qaf
CADItem;56500000001295;A1;IMAN_specification;UGPART;56500000 001295_dr01;qaf;
qafmetadata.qaf
CADItem;56500000001295;A1;IMAN_specification;UGPART;56500000 001295_dr01;prt;
56500000001295_dr01.prt
CADItem;56500000001295;A6;IMAN_specification;TIFFDrawing;565 00000001295_dr01
;tif;56500000001295_dr01.tif
CADItem;56500000001295;A6;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
images_preview.qaf
CADItem;56500000001295;A6;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
qafmetadata.qaf
##############################################

I have to tokenize each string and get item and
revision(ex:56500000001295;A4)

Output like:
################
56500000001295;A4
56500000001295;A2
56500000001295;A5
56500000001295;A3
56500000001295;A1
56500000001295;A6

So I want each line should be unique. No multiple entries.
I hope this can help for understanding.

Thanks and Regards
Reddy

-----Original Message-----
From: Nathan Haigh [mailto:n.haigh@sheffield.ac.uk]
Sent: 27 February 2007 09:28
To: Beri Veera-ext, Reddy
Cc: ActivePerl
Subject: [RMX:#] Re: [RMX:#] Re: [RMX:#] Re: [RMX:#] Re: How to compare two
files and update t o second fil e

Beri Veera-ext, Reddy wrote:
> Hi,
> Thanks for your information. I want output like this only. If I have
> multiple lines I should take first line only.
>
> Thanks and Regards
> Reddy
>
>

I am still not clear what you want as your final output file! Please,
please clarify with an example output file!

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: [RMX:#] Re: [RMX:#] Re: [RMX:#] Re: [RMX:#] Re: How to compar

am 27.02.2007 09:48:12 von n.haigh

Beri Veera-ext, Reddy wrote:
> Hi,
> Sorry for trouble.
> Input file:
> ##############################
> CADItem;56500000001295;A4;IMAN_specification;TIFFDrawing;565 00000001295_dr01
> ;tif;56500000001295_dr01.tif
> CADItem;56500000001295;A4;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
> images_preview.qaf
> CADItem;56500000001295;A4;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
> qafmetadata.qaf
> CADItem;56500000001295;A4;IMAN_specification;UGMASTER;565000 00001295-A1;prt;
> 56500000059898_A1.prt
> CADItem;56500000001295;A4;IMAN_specification;UGPART;56500000 001295_dr01;qaf;
> dwg_sht1.qaf
> CADItem;56500000001295;A4;IMAN_specification;UGPART;56500000 001295_dr01;qaf;
> qafmetadata.qaf
> CADItem;56500000001295;A4;IMAN_specification;UGPART;56500000 001295_dr01;prt;
> 56500000001295_dr01.prt
> CADItem;56500000001295;A2;IMAN_specification;TIFFDrawing;565 00000001295_dr01
> ;tif;56500000001295_dr01.tif
> CADItem;56500000001295;A2;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
> images_preview.qaf
> CADItem;56500000001295;A2;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
> qafmetadata.qaf
> CADItem;56500000001295;A2;IMAN_specification;UGMASTER;565000 00001295-A1;prt;
> 56500000059898_A1.prt
> CADItem;56500000001295;A2;IMAN_specification;UGPART;56500000 001295_dr01;qaf;
> dwg_sht1.qaf
> CADItem;56500000001295;A2;IMAN_specification;UGPART;56500000 001295_dr01;qaf;
> qafmetadata.qaf
> CADItem;56500000001295;A2;IMAN_specification;UGPART;56500000 001295_dr01;prt;
> 56500000001295_dr01.prt
> CADItem;56500000001295;A5;IMAN_specification;TIFFDrawing;565 00000001295_dr01
> ;tif;56500000001295_dr01.tif
> CADItem;56500000001295;A5;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
> images_preview.qaf
> CADItem;56500000001295;A5;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
> qafmetadata.qaf
> CADItem;56500000001295;A5;IMAN_specification;UGMASTER;565000 00001295-A1;prt;
> 56500000059898_A1.prt
> CADItem;56500000001295;A5;IMAN_specification;UGPART;56500000 001295_dr01;qaf;
> dwg_sht1.qaf
> CADItem;56500000001295;A5;IMAN_specification;UGPART;56500000 001295_dr01;qaf;
> qafmetadata.qaf
> CADItem;56500000001295;A5;IMAN_specification;UGPART;56500000 001295_dr01;prt;
> 56500000001295_dr01.prt
> CADItem;56500000001295;A3;IMAN_specification;TIFFDrawing;565 00000001295_dr01
> ;tif;56500000001295_dr01.tif
> CADItem;56500000001295;A3;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
> images_preview.qaf
> CADItem;56500000001295;A3;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
> qafmetadata.qaf
> CADItem;56500000001295;A3;IMAN_specification;UGMASTER;565000 00001295-A1;prt;
> 56500000059898_A1.prt
> CADItem;56500000001295;A3;IMAN_specification;UGPART;56500000 001295_dr01;qaf;
> dwg_sht1.qaf
> CADItem;56500000001295;A3;IMAN_specification;UGPART;56500000 001295_dr01;qaf;
> qafmetadata.qaf
> CADItem;56500000001295;A3;IMAN_specification;UGPART;56500000 001295_dr01;prt;
> 56500000001295_dr01.prt
> CADItem;56500000001295;A1;previous_TIFF;TIFFDrawing;56500000 001295_dr01;tif;
> 56500000001295_dr01.tif
> CADItem;56500000001295;A1;IMAN_specification;TIFFDrawing;565 00000001295_dr01
> ;tif;56500000001295_dr01.tif
> CADItem;56500000001295;A1;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
> images_preview.qaf
> CADItem;56500000001295;A1;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
> qafmetadata.qaf
> CADItem;56500000001295;A1;IMAN_specification;UGMASTER;565000 00001295-A1;prt;
> 56500000059898_A1.prt
> CADItem;56500000001295;A1;IMAN_specification;UGPART;56500000 001295_dr01;qaf;
> dwg_sht1.qaf
> CADItem;56500000001295;A1;IMAN_specification;UGPART;56500000 001295_dr01;qaf;
> qafmetadata.qaf
> CADItem;56500000001295;A1;IMAN_specification;UGPART;56500000 001295_dr01;prt;
> 56500000001295_dr01.prt
> CADItem;56500000001295;A6;IMAN_specification;TIFFDrawing;565 00000001295_dr01
> ;tif;56500000001295_dr01.tif
> CADItem;56500000001295;A6;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
> images_preview.qaf
> CADItem;56500000001295;A6;IMAN_specification;UGMASTER;565000 00001295-A1;qaf;
> qafmetadata.qaf
> ##############################################
>
> I have to tokenize each string and get item and
> revision(ex:56500000001295;A4)
>
> Output like:
> ################
> 56500000001295;A4
> 56500000001295;A2
> 56500000001295;A5
> 56500000001295;A3
> 56500000001295;A1
> 56500000001295;A6
>
> So I want each line should be unique. No multiple entries.
> I hope this can help for understanding.
>
> Thanks and Regards
> Reddy
>


OK, so you only want the item and revision bits from the input file and
you only want unique one's at that? If this is all you want to do, you
have no need to read what's in the output file. The script below should
do what you want. Simply execute with the input file as the 1st argument
to the script and you can redirect STDOUT to a file.

e.g.
perl this_script.pl input.txt > output.txt

I have sorted the items alphabetically, if you need the items in the
order they were encountered in the input file, this will need to be
changed slightly.

Let me know if this works as you want.

Nathan

-- code start --
#!/usr/bin/perl -w

use strict;

my %item_rev; # use this to keep track of what item and revisions are
encountered

open (INPUT, $ARGV[0]) or die "Couldn't open input file '$ARGV[0]': $!\n";
while () {
# skip all lines except those starting "CADItem"
next unless /^CADItem/;

# split the line into it's component fields
my
($item_type,$item_id,$item_revision,$relation,$datsettype,$d ataset) =
split /;/;

if (exists $item_rev{"$item_id;$item_revision"} ) {
# we already found the 1st occurence of this item and revision
} else {
# this must be the first occurence
$item_rev{"$item_id;$item_revision"} = 1;
}
}
close INPUT;

# %item_rev now contains a unique list of items with revisions
foreach my $item_with_rev (sort keys%item_rev) { print STDOUT
"$item_with_rev\n"; }
-- code end --
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: [RMX:#] Re: [RMX:#] Re: [RMX:#] Re: [RMX:#] Re: How to compar

am 27.02.2007 09:51:34 von n.haigh

-- snip --
>
> OK, so you only want the item and revision bits from the input file and
> you only want unique one's at that? If this is all you want to do, you
> have no need to read what's in the output file. The script below should
> do what you want. Simply execute with the input file as the 1st argument
> to the script and you can redirect STDOUT to a file.
>
> e.g.
> perl this_script.pl input.txt > output.txt
>
> I have sorted the items alphabetically, if you need the items in the
> order they were encountered in the input file, this will need to be
> changed slightly.
>
> Let me know if this works as you want.
>
> Nathan
>
> -- code start --
> #!/usr/bin/perl -w
>
> use strict;
>
> my %item_rev; # use this to keep track of what item and revisions are
> encountered
>
> open (INPUT, $ARGV[0]) or die "Couldn't open input file '$ARGV[0]': $!\n";
> while () {
> # skip all lines except those starting "CADItem"
> next unless /^CADItem/;
>
> # split the line into it's component fields
> my
> ($item_type,$item_id,$item_revision,$relation,$datsettype,$d ataset) =
> split /;/;
>
> if (exists $item_rev{"$item_id;$item_revision"} ) {
> # we already found the 1st occurence of this item and revision
> } else {
> # this must be the first occurence
> $item_rev{"$item_id;$item_revision"} = 1;
> }
> }
> close INPUT;
>
> # %item_rev now contains a unique list of items with revisions
> foreach my $item_with_rev (sort keys%item_rev) { print STDOUT
> "$item_with_rev\n"; }
> -- code end --
> _______________________________________________
> ActivePerl mailing list
> ActivePerl@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>

Ouch - sorry for the line wrap!! Hopefully, you can figure it out!

Nathan
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs