Page 1 of 1
creating a list with missing numbers
Posted: Wed Feb 13, 2013 9:02 am
by jan-01
Hello , is it possible to create a list with lacking numbers?
This list (a short example) starts with 'm b 157 n+ and as you can see, the numbers 160-165 are missing, can I create a list with those numbers in textad?
Thanks in advance
Jan
M b 157 N+
M b 158 N+
M b 159 N+
M b 166 N+
M b 174 N+
M b 180 N+
M b 183 N+
M b 185 N+
M b 187 N+
M b 188 N+
M b 205 N+
M b 207 N+
M b 209 N+
M b 210 N+
M b 216 N+
M b 217 N+
M b 218 N+
M b 219 N+
M b 220 N+
M b 221 N+
M b 222 N+
M b 225 N+
M b 226 N+
M b 229 N+
M b 231 N+
M b 232 N+
M b 233 N+
M b 234 N+
M b 234 N+
M b 239 N+
Posted: Wed Feb 13, 2013 11:09 am
by ak47wong
You can, but you have to set up the required number of lines first. In your example you need 6 lines so create a file containing the following:
M b # N+
M b # N+
M b # N+
M b # N+
M b # N+
M b # N+
Then perform a Replace operation with the following parameters:
Find what: #
Replace with: \i(160)
Select Regular expression and click Replace All.
Posted: Wed Feb 13, 2013 12:23 pm
by jan-01
Thanks for your reaction,
I think this was a bad example/quistion of me
I mean how to discover the missing numbers and make a list of those numbers, between 157 and 239.
Jan
M b 157 N+
M b 158 N+
M b 159 N+
M b 166 N+
M b 174 N+
M b 180 N+
M b 183 N+
M b 185 N+
M b 187 N+
M b 188 N+
M b 205 N+
M b 207 N+
M b 209 N+
M b 210 N+
M b 216 N+
M b 217 N+
M b 218 N+
M b 219 N+
M b 220 N+
M b 221 N+
M b 222 N+
M b 225 N+
M b 226 N+
M b 229 N+
M b 231 N+
M b 232 N+
M b 233 N+
M b 234 N+
M b 234 N+
M b 239 N+
Posted: Wed Feb 13, 2013 1:18 pm
by ak47wong
Sorry for the misunderstanding. There's no simple way to do it that I can think of, but here's one solution, which doesn't actually use TextPad and which also requires a separate utility.
Firstly, create a file that contains the data with the missing numbers. Call this file
short.txt.
Second, create another file, called
long.txt, containing the complete set of lines from 157 to 239, as follows:
- Open a Command Prompt window.
- Enter the command: for /L %I in (157,1,239) do echo M b %I N+>>long.txt
Finally, compare the files using the UNIX command
comm, displaying only the lines that are in
long.txt but not in
short.txt:
- Download this set of Unix-like utilities: http://sourceforge.net/projects/unxutils/
- Extract the file usr\local\wbin\comm.exe from the archive UnxUtils.zip.
- At the command prompt, enter the command: comm -1 -3 short.txt long.txt
Posted: Wed Feb 13, 2013 3:17 pm
by jan-01
Hello ak47wong,
Thanks for your advice and example
I know someone with unix skills and unix machine
Jan
Posted: Wed Feb 13, 2013 4:35 pm
by ben_josephs
Then this might be a solution:
where
missingnums.pl is
Code: Select all
use warnings ;
use strict ;
my %nums ;
while ( my $line = <> )
{
my $n = ( $line =~ /(\d+)/ )[ 0 ] ;
$nums{ $n } = 1 ;
}
my @nums = sort keys %nums ;
my $lo = $nums[ 0 ] ;
my $hi = $nums[ $#nums ] ;
for my $n ( $lo .. $hi )
{
if ( ! $nums{ $n } )
{
print "$n\n" ;
}
}