If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Shell script to check the unique numbers in huge data

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-10-07, 03:43
namishtiwari namishtiwari is offline
Registered User
 
Join Date: Aug 2007
Posts: 21
Thumbs up Shell script to check the unique numbers in huge data

Friends,
I have to write a shell script,the description is----

i Have to check the uniqueness of the numbers in a file.
A file is containing 200thousand tickets and a ticket have 15 numbers in asecending order.And there is a strip that is having 6 tickets that means 90 numbers.I have to write a shell script like this----- No two tickets are common in 200thousand tickets and no two numers are repeating in a strip.
I would appericiate your help.

If you want some more info i am pasting it here.
---------------------------------------------------
Each ticket strip will have six tickets.
A strip is a group of 6 tickets. Every possible number from 1 through to 90 will appear on each full strip.
Each ticket will have 9 columns, and 3 rows. Hence a ticket strip will effectively have 9 columns and 18 rows.
Column 1 will have numbers between 1-9, 2 will have 10-19, so on till 8th column having 70-79; the only exception is the last column (9th column) having 80-90.
In each row there will be only 5 columns generated, the other 4 will be blank.
If there are more than 1 value in a column within a ticket, then they should be in ascending order.
Reply With Quote
  #2 (permalink)  
Old 08-10-07, 04:56
namishtiwari namishtiwari is offline
Registered User
 
Join Date: Aug 2007
Posts: 21
Here is the format of the file.

insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (100,1,'071400004200007480000021364450660000001623 390000007784',1);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (101,1,'050000004055627100001028330000680087080000 004959007988',2);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (102,1,'001522300054600000060000004156007090091926 310000610000',3);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (103,1,'000000004652677685011329384700000000001700 000057697886',4);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (104,1,'020020340000007581001825004351640000030027 370000650083',5);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (105,1,'041100004553007200000024324800630082001200 350058007389',6);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (106,2,'000022340057007685071027004800620000000000 360059687789',1);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (107,2,'021221004600000090051500310050007100080024 004700617800',2);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (108,2,'001300334553000084040026000056657500001800 394900660086',3);

Last edited by namishtiwari; 08-10-07 at 05:27.
Reply With Quote
  #3 (permalink)  
Old 08-10-07, 05:30
namishtiwari namishtiwari is offline
Registered User
 
Join Date: Aug 2007
Posts: 21
Thumbs up

Here is the format of the data---

insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (100,1,'071400004200007480000021364450660000001623 390000007784',1);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (101,1,'050000004055627100001028330000680087080000 004959007988',2);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (102,1,'001522300054600000060000004156007090091926 310000610000',3);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (103,1,'000000004652677685011329384700000000001700 000057697886',4);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (104,1,'020020340000007581001825004351640000030027 370000650083',5);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (105,1,'041100004553007200000024324800630082001200 350058007389',6);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (106,2,'000022340057007685071027004800620000000000 360059687789',1);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (107,2,'021221004600000090051500310050007100080024 004700617800',2);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (108,2,'001300334553000084040026000056657500001800 394900660086',3);


The requirement is like this---

1 strip is having six tickets containing all 90 numbers.
This number should be unique.
Reply With Quote
  #4 (permalink)  
Old 08-10-07, 05:49
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Would this be useful?
Code:
IF EXISTS (SELECT id FROM sysobjects WHERE id = object_id('MyTable')) BEGIN
	DROP TABLE MyTable
END

DECLARE @x int, @RepeatCount int, @Value char(9)
SET @x = 0
SET @RepeatCount = 100

CREATE TABLE MyTable(SomeField char(9))

WHILE @x < @RepeatCount BEGIN
	SET @Value = convert(varchar,replicate(0,9 - Len(@x))) + convert(varchar,@x)
	INSERT INTO MyTable(SomeField) VALUES (@Value)
	SET @x = @x + 1
END

SELECT * FROM MyTable
DROP TABLE MyTable
__________________
George
Twitter | Blog
Reply With Quote
  #5 (permalink)  
Old 08-10-07, 05:55
namishtiwari namishtiwari is offline
Registered User
 
Join Date: Aug 2007
Posts: 21
Thanks georgev,
I will try this one.Can you suggest something in shell script.

I appericiate your help.
Reply With Quote
  #6 (permalink)  
Old 08-10-07, 05:57
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Well I don't really understand your requirements, and I don't know shell...
I was merely commenting on the SQL you were using and having a guess.

Run the script and let me know if it gives you the required effect.
__________________
George
Twitter | Blog
Reply With Quote
  #7 (permalink)  
Old 08-10-07, 06:52
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Quote:
Originally Posted by namishtiwari
Here is the format of the data---

insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (100,1,'071400004200007480000021364450660000001623 390000007784',1);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (101,1,'050000004055627100001028330000680087080000 004959007988',2);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (102,1,'001522300054600000060000004156007090091926 310000610000',3);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (103,1,'000000004652677685011329384700000000001700 000057697886',4);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (104,1,'020020340000007581001825004351640000030027 370000650083',5);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (105,1,'041100004553007200000024324800630082001200 350058007389',6);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (106,2,'000022340057007685071027004800620000000000 360059687789',1);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (107,2,'021221004600000090051500310050007100080024 004700617800',2);
insert into Ticket (TicketID,TicketStripID,TicketData,SequenceNo) values (108,2,'001300334553000084040026000056657500001800 394900660086',3);


The requirement is like this---

1 strip is having six tickets containing all 90 numbers.
This number should be unique.
Do you have the data in a file or in such an SQL script? If it is a SQL script, does your requirement include to evaluate the data inside a database?

If it is in a flat file, you could build a shell script that extracts the portions of the data you are interested in, combine these portions into a single line for each record, and then run "sort" or "sort -u". Comparing the line count of "sort" and "sort -u" tells you if there were duplicates found and eliminated by "sort -u".
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #8 (permalink)  
Old 08-10-07, 08:25
namishtiwari namishtiwari is offline
Registered User
 
Join Date: Aug 2007
Posts: 21
Arrow

Thanks for the help experts.
jsut now the they change the requirement,
i have pasted the requirement as a new thread by my name.
Please help me in that.

Thanks in advance.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On