COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### To remove the duplicate record in the list using java

• Email
• Follow

Sir/MadamWe have a list of Record with the unqiue key like account no, and sequence no, and the rest of fields are exactly the same.Any way for java to remove those duplicated records?Thanks
 0
Reply timcons1 (42) 9/18/2007 2:02:34 AM

See related articles to this posting

On Tue, 18 Sep 2007 02:02:34 GMT, "timothy ma and constance lee"
<timcons1@shaw.ca> wrote, quoted or indirectly quoted someone who said
:

>We have a list of Record with the unqiue key like account no, and sequence
>no, and the rest of fields are exactly the same.
>Any way for java to remove those duplicated records?

For a canned solution, see http://mindprod.com/products2.html#SORTED
--
The Java Glossary
http://mindprod.com

 0

timothy ma and constance lee wrote:...>We have a list of Record with the unqiue key like account no, and sequence >no, ..If every record has a unique key formed from account& seqence number, how cany any two records beidentical, or duplicate?*>..and the rest of fields are exactly the same.>Any way for java to remove those duplicated records?I do not fully understand the question.The way you describe the records, I guess it it might be something like (fixed width font required for proper viewing)..Acc. #  | Seq. # | Field1  | Field2 | Field3121045     2       cat       dog      fish415386     3       giraffe   dog      fish848345     7       cat       dog      fish900277     4       frog      cow      whale..and you are saying you want to remove duplicates in Fields1 through 3.  So the first and third record are'duplicates' but the second (with Giraffe) and 4th are not?Am I on track so far?* If that is the case, and records 1 and 3 are considered 'duplicates' which one should be dumped?-- Andrew Thompsonhttp://www.athompson.info/andrew/Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200709/1
 0

AndrewSomething like thatAccount No  Seq No    Name123456        001          abc123456        001          abc123234        001           xyz123234        002           abd1123421        002           ijkThe message may be from some Mainframe that we dont want fix it Mainframe level. SImply using java to remove the duplicated one:123456    001    abcThanks"Andrew Thompson" <u32984@uwe> wrote in message news:7861e17ba18ec@uwe...> timothy ma and constance lee wrote:> ..>>We have a list of Record with the unqiue key like account no, and sequence>>no, ..>> If every record has a unique key formed from account> & seqence number, how cany any two records be> identical, or duplicate?*>>>..and the rest of fields are exactly the same.>>Any way for java to remove those duplicated records?>> I do not fully understand the question.>> The way you describe the records, I guess it> it might be something like (fixed width font> required for proper viewing)..>> Acc. #  | Seq. # | Field1  | Field2 | Field3> 121045     2       cat       dog      fish> 415386     3       giraffe   dog      fish> 848345     7       cat       dog      fish> 900277     4       frog      cow      whale>> .and you are saying you want to remove duplicates> in Fields1 through 3.  So the first and third record are> 'duplicates' but the second (with Giraffe) and 4th are> not?>> Am I on track so far?>> * If that is the case, and records 1 and 3 are> considered 'duplicates' which one should be> dumped?>> -- > Andrew Thompson> http://www.athompson.info/andrew/>> Message posted via JavaKB.com> http://www.javakb.com/Uwe/Forums.aspx/java-general/200709/1>
 0

On Sep 17, 8:35 pm, "timothy ma and constance lee" <timco...@shaw.ca>
wrote:
> "Andrew Thompson" <u32984@uwe> wrote in messagenews:7861e17ba18ec@uwe...
> > timothy ma and constance lee wrote:
> > ..
> >>We have a list of Record with the unqiue key like account no, and sequence
> >>no, ..
>
> > If every record has a unique key formed from account
> > & seqence number, how cany any two records be
> > identical, or duplicate?*
>
> >>..and the rest of fields are exactly the same.
> >>Any way for java to remove those duplicated records?
>
> > I do not fully understand the question.
>
> > The way you describe the records, I guess it
> > it might be something like (fixed width font
> > required for proper viewing)..
>
> > Acc. #  | Seq. # | Field1  | Field2 | Field3
> > 121045     2       cat       dog      fish
> > 415386     3       giraffe   dog      fish
> > 848345     7       cat       dog      fish
> > 900277     4       frog      cow      whale
>
> > .and you are saying you want to remove duplicates
> > in Fields1 through 3.  So the first and third record are
> > 'duplicates' but the second (with Giraffe) and 4th are
> > not?
>
> > Am I on track so far?
>
> > * If that is the case, and records 1 and 3 are
> > considered 'duplicates' which one should be
> > dumped?
>
> > --
> > Andrew Thompson
> >http://www.athompson.info/andrew/
>
> > Message posted via JavaKB.com
> >http://www.javakb.com/Uwe/Forums.aspx/java-general/200709/1
> Andrew
>
> Something like that
>
> Account No  Seq No    Name
> 123456        001          abc
> 123456        001          abc
> 123234        001           xyz
> 123234        002           abd1
> 123421        002           ijk
>
> The message may be from some Mainframe that we dont want fix it Mainframe
> level. SImply using java to remove the duplicated one:
>
> 123456    001    abc
>
> Thanks
>

Try using a Set (probably HashSet or LinkedHashSet depending).  You'll
have to make sure that your object properly implements hashCode() and
equals(), but that shouldn't be too hard...

4. It makes it hard to follow the conversation.
1. I like to top post.

Good luck,
Daniel.


 0

timothy ma and constance lee wrote:...Please refrain from top-posting.  I find it most confusing.Notice how both Roedy and myself put our comments directly after anything worth replying to?  In best situations,we would then trim other parts of earlier messages thatwe are not commenting on.  That technique is known as'in-line with trim' posting - and is much easier to follow.>Something like that>>Account No  Seq No    Name>123456        001          abc>123456        001          abc>123234        001           xyz>123234        002           abd1>123421        002           ijkOK.  So I was wrong in guessing that the Acc./Seq. #was unique in all cases - they can also be duplicate.>The message may be from some Mainframe that we dont want fix it Mainframe >level. SImply using java to remove the duplicated one:>>123456    001    abcI suspect (without looking at the link Roedy posted)that sorting the records is one technique that might identify duplicates, but there are also other ways.For example, you might iterate the entire original listand on each iteration of the loop.- Make an object that uses all the fields as a 'key'- Use that  key to check if a record with that key already exists in a HashMap.- If not..   - add the object to the HashMap,..else..  - discard it as a duplicate.At the end of the loop, the HashMap should containonly the unique records.-- Andrew Thompsonhttp://www.athompson.info/andrew/Message posted via http://www.javakb.com
 0

timothy ma and constance lee wrote:> The message may be from some Mainframe that we dont want fix it Mainframe > level.How do you receive the message?If your records comes from the SQL database, you may simply achieve your goal using "SELECT DISTINCT ... " instead of a regular "SELECT ..." statement.If there are some additional data being read with an SQL query, there is usually also possibility to read the rows in order which is consistent (partially at least) with your uniqueness key.  Because database keys are usually already indexed, it should cost nothing if you'll choose your database keys in ORDER BY clause to achieve the right order. Having even partially sorted records at Java side you may significantly seed up your process (of course, if it all is really worth of it).Otherwise, just follow some of the already suggested solutions.piotr
 0

timothy ma and constance lee wrote:>> Account No  Seq No    Name>> 123456        001          abc>> 123456        001          abc>> 123234        001           xyz>> 123234        002           abd1>> 123421        002           ijkAndrew Thompson wrote:> OK.  So I was wrong in guessing that the Acc./Seq. #> was unique in all cases - they can also be duplicate.That wasn't a guess:timothy ma and constance lee wrote:> We have a list of Record with the unqiue [sic] key > like account no, and sequence no,They actually said so, then contradicted it with the data example.-- Lew
 0

"timothy ma and constance lee" <timcons1@shaw.ca> wrote in news:_HHHi.194784$fJ5.28279@pd7urf1no:> Andrew> > Something like that> > Account No Seq No Name> 123456 001 abc> 123456 001 abc> 123234 001 xyz> 123234 002 abd1> 123421 002 ijk> > The message may be from some Mainframe that we dont want fix it Mainframe > level. SImply using java to remove the duplicated one:> > 123456 001 abcQuestions:1. do you already have a Java object that encapsulates a record of data? If not, can you implement one?2. does this Java object implement java.lang.Comparable? If not, can it be made to do so?3. if you have two duplicate records in the sequence of records, would you rather end up (after you do your processing to remove duplicates) wiht the first record, or would you rather end up with the last record of the duplicates?Suggestion:use a java.util.Set of objects (that must implement Comparable) to eliminate duplicates. When you've added all of your collection of record objects to the Set, you will end up with a collection with no duplicates.RegardsGRB-- ---------------------------------------------------------------------Greg R. Broderick usenet200709@blackholio.dyndns.orgA. Top posters.Q. What is the most annoying thing on Usenet?---------------------------------------------------------------------  0 Reply Greg 9/18/2007 10:50:41 PM Greg R. Broderick wrote:> 3. if you have two duplicate records in the sequence of records, would you > rather end up (after you do your processing to remove duplicates) wiht the > first record, or would you rather end up with the last record of the > duplicates?A meaningless distinction in many data systems, such as SQL-based ones.For example, SQL queries make no promises about order of records absent an ORDER BY clause, and even then, none about ordering of equal values.-- Lew  0 Reply Lew 9/18/2007 11:10:11 PM 9 Replies 146 Views Similar Articles 12/10/2013 9:39:48 PM page loaded in 106023 ms. (0)  Reply: Similar Artilces: Syntax to add records if primary key = list I am new to SQL administration. >From a list of IDs that are the primary key in one table (i.e. Customer Table), I want to make changes in tables that use those IDs as a foreign key. Basically I want to say: If fk_ID is in list [1,2,3,4,5] then do these statements to that record End if Where do I begin? Thanks for help with this low-level view of SQL programming. -tom > I am new to SQL administration. > > >From a list of IDs that are the primary key in one table (i.e. Customer > Table), I want to make changes in tables that use those IDs as a > f... Using listings package to highlight numbers in code Dear all, I am using the listings package for a very simple code listing. I would like every number (we are talking integers here so no decimal point to worry about) to be highlighted red. I have tried the following settings: \documentclass[10pt,a4paper]{article} \usepackage{listings} \usepackage{color} \begin{document} \begin{lstlisting}[emph={0,1,2,3,4,5,6,7,8,9}, emphstyle=\color{red}] This is a test 123 + 456 = 789 \end{lstlisting} \end{document} but no success. Can anyone offer any suggestions? Many thanks in advance, Paul -- Department of Computing, Imperial College London ht... How to get list of files from http server using beans. I must to get a list of files which are under http address. Could you give me some advice? I heard that beans could help me. szymex wrote: > I must to get a list of files which are under http address. Could you give > me some advice? I heard that beans could help me. You can't. There's no such thing as a list of files as far as http is concerned. You could get the URL's out of an autogenerated index page though. Just retrieve that page first, and then retrieve all the URL's in that page. To actually retrieve those files, look at the java.net.* classes, or http://ja... form combo boxes giving duplicate record error I have 6 tables total, 5 of them have two fields, ID and name, like so: Table1 (ID1, name1) Table2 (ID2, name2) .... Table5 (ID5, name5) The last table is an intersection table that brings in all the 5 tables IDs with a 1:M relationship to each table like so: IntersectTable (ID1_FK,ID2_FK,ID3_FK,ID4_FK,ID5_FK) Now I built a form and a subform that enables me to view all the combinations entered in the IntersectTable by name. I want the functionality to update the Intersect table by adding new records but everytime I run into an update error thats says I'm trying to create duplicates. ... how to "auto-hide" a window using Java? Dear folks, How to auto -hide a window, then when the mouse move over a certain very slim region, the window gradually move out and show. How can I implement this on Linux and Windows XP using Java? Thanks a lot, -Gino gino wrote: > How to auto -hide a window, then when the mouse move over a certain very > slim region, the window gradually move out and show. How can I implement > this on Linux and Windows XP using Java? You could detect this easily with MouseEvent, looking for enter and leave. The animated motion is probably best done with a javax.swing.Timer, and of cour... applet using JVM 1.1 Hi, I have the need to render some data on my applet using the "Lucida Console" font. The problem is that we have to support MS versions of the JVM therefore cannot make use of any of the rather cool Java2D functionality. Does anyone know if I can still load fonts that are outside of the Toolkit.getFontList() array? Regards, Steve ... Can I use somehow use CAT5 instead of COAX for SPDIF? I need to get SPDIF audio into my bedroom from my living room. I was planning to run RG6, but thought that if I could run CAT5 instead, I would have a more future usable piece of cable. Besides, its much easier to handle CAT5 instead of stiff RG6. Can anybody provide any tips? THANKS! --Dan "dg" <dan_gus@hotmail.com> wrote in message news:%kzad.1960$6q2.1491@newssvr14.news.prodigy.com... > I need to get SPDIF audio into my bedroom from my living room. I was > planning to run RG6, but thought that if I could run CAT5 instead, I would > have a more future usable...

What is #pragma once used for
What is #pragma once used for and what is #WIN#@_LEN_AND_MEAN "raashid bhatt" <raashidbhatt@gmail.com> wrote in message news:e3fd7779-809d-4368-97a2-e9c2724b58dd@59g2000hsb.googlegroups.com... > What is #pragma once used for > and > what is #WIN#@_LEN_AND_MEAN It is a preprocessor directive. You'd have to look it up in the documentation for your compiler. Judging by your second question, MSDN Library would be the place to look. The first is usually for turning off compiler warnings and the second is an arifact from the old days when someone would make a wind...

How do I use sendmail
I need sendmail to act as a mta to my isp's mailserver (postfix) with auth. Is that possible? -- "Some secrets can bring only catastropy" Valerij Legasov "Gunnar Gren" <gg@invalid.invalid> wrote in message news:4f2e188e$0$76361$afc38c87@read01.usenet4all.se... > I need sendmail to act as a mta to my isp's mailserver (postfix) > with auth. Is that possible? Yes. Den 2012-02-05 skrev Gunnar Gren <gg@invalid.invalid>: > > I need sendmail to act as a mta to my isp's mailserver (postfix) > with auth. Is that possible? > > ... duplicates in @INC Hi, perl -le 'print join "\n", @INC' shows me this: /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 . See the first 2 search paths and the last 2 ( before the . ) are duplicates and I want to remove the duplicate... Using popen Can anyone please give me a full example on how to use popen to both wirte and read from a datastream? (Please also give me which header files I should include, I'm using Visual C++ 6) Thanks, Mark nlmark@hotmail.com wrote: > Can anyone please give me a full example on how to use popen to both > wirte and read from a datastream? (Please also give me which header > files I should include, I'm using Visual C++ 6) Two points: 1. This is off-topic here, as _popen is not part of the C++ standard. 2. All the information you request is in the help files for Visual C++. Also chec... Java Profiler and IPlanet I would like to use a Java Profiler to give me a trace of which classes and methods get used in a web-app, for servlets, JSP's, and other Java classes. My client is using an ancient app server: IPlanet Web Server 6.0 SP2 (Former name of Sun Java System Web Server), with Java 1.2.2 on a Solaris box. Can somebody suggest a good Profiler, hopefully one that works with that combination? "HowieG" <howardg22@yahoo.com> wrote in message news:1111621661.440058.88430@z14g2000cwz.googlegroups.com... > I would like to use a Java Profiler to give me a trace of which classes > ... Record could not be found (Generator) Tried opening an app today (yesterday it worked fine). Got the message "Record could not be found (Module: 3)". Does anybody know what that means (and what to do about it)? Thanks, Peter Tried opening the .bpp file instead after renaming - same error. Peter "Peter Hermansen" <peter@_no_spam_opex.dk> skrev i en meddelelse news:3f2e713d$1@news.softvelocity.com... > Tried opening an app today (yesterday it worked fine). Got the message > "Record could not be found (Module: 3)". > > Does anybody know what that means (and what to do about it)? &...

How to remove a serial interface
Hello I'm trying to remove a serial interface in a cisco 3640 but I dont know how. I tryed just removing it but my adsl configuration stopped working. A no interface is not working. Thank you all. Pablo. if the interface is physically installed it will appear in your Cfg. If this is the case, goto config mode and enter the "interface serial 0/0" and the "shutdown". If you have a Cfg, were a serial interface appears that you have just removed from the router. Then it will be there untill you reload the router. At boot time if will remove the Cfg entries from running ...

Grouping list elements
At one point I recall reading in a Lisp book about a function which would take a list as input and break it up into a list of n-element sublists plus the remainder, e.g. (foo 3 '(1 2 3 4 5 6 7)) => ((1 2 3) (4 5 6) (7)) The trouble is I can't remember its name, or whether it was standard or a user-defined function. I looked through the HyperSpec and c.l.l for all the synonyms of "group", "partition", etc I could think of, but found nothing. Does anyone know what I'm thinking of? In article <1129240038.784097.245850@g47g2000cwa.googlegroups.com>...

Bit Manipulation in Java
Hello, I am new to working with the bit operators in java and need to implement an algorightm and was hoping to get some guidance to address the questions or url to material that may help. 1) I am starting out a byte array of lenght 20. 2) Next I need to determin the offsetbits, which are supposed to to be the low order 4 bits of byte[19]. How do I determine this? 3)How do I convert this value in to an Int ? Thanks in advance for your help. Leslie > 1) I am starting out a byte array of lenght 20. byte [] b = new byte[20]; > 2) Next I need to determin the offsetbits, which are s...

How to use previous values?
I'm fairly new to Matlab, so perhaps my question seems stupid. I have over 1000 values from an Excel-file imported into Matlab. Now I want to create a plot wich displays a start value of 200 and then decreases with the values from the Excel-file. For example: Values from Excel are 10 20 40 20 5 25 Now I want to plot the following values: 200-10 200-10-20 200-10-20-40 200-10-20-40-20 200-10-20-40-20-5 200-10-20-40-20-5-25 How can I do this? Thanks in advance. "Gert-Leon " <glvanlier@gmail.com> wrote in message news:jpd7iu$rt4$1@newscl01ah.mathworks.com... > I'...

Suitable for real use?
Hi, I'm interested in Minix, but I have one question that is still on my mind. Is Minix suitable for real work / development and as a general desktop operating system? ..Or is it only good for educational purposes? Thank you, - Steve I think minix is originally developed for education purposes. I guess they're now trying to make it suitable for some general purpose computing. (just my opinion). Lord2k@gmail.com wrote: > Hi, I'm interested in Minix, but I have one question that is still on > my mind. Is Minix suitable for real work / development and as a general > des...

Help with List view
Hello. before I paste my code I will try and explain what I am trying to achieve. I have loaded a txt file which contains 26,000 items into a listview I want to be able to enter some text into a text box and when I press a command button it Removes all items from the listview that DOES NOT match what I have entered in the text box. Although the code below works, it is extremely SLOW. can anyone help me improve this, (example code would be great) Regards Ian Private Sub cmdok_Click() Dim SearchItem As String SearchItem = LCase$(Trim$(txtfind)) 'txtfind is a textbox Dim i As Long Me.Mous...

Using Modules as Decorators
Someone recently mentioned the idea of using Modules to implement the Decorator pattern (though I can't find the post now, so maybe I imagined it). It got me thinking and today I sat down to see if I could do it. I ended up with a module Decorator,that can be included into another module to turn it into a decorator. You can then extend an object with the decorator to decorate it. The next part is that methods defined in the decorator can use a call_orig method to call to original method that they are replacing. For example: module Test include Decorator def foo print "Tes...