Filter an array of arrays based on some criteria

Hi Folks:
Is there a way to filter an array of arrays based on some criteria?
Say I have the below set of records in an array of arrays. testArr[][]
ID     DTLNUM           PARTNUM          PARTDESC
AB11     AB11-1           6531079          bath towel
AB11     AB11-2           5122830          bathtub mat
AB11     AB11-3           3649100          shower curtain
AB11     AB11-4           1143784          hamper
AB11     AB11-5            2672324          bath scaleI want to filter the above array and get all records having PARTDESC beginning with the letters "bath" into another array of arrays, resultArr[][] //I want to get the result in this one.
How could this be done?
Please help.
Thank you for your time.

Say I have the below set of records in an array of arrays. testArr[][]
Why array of arrays? Why not an array of objects of a class say 'Part'?
class Part{
     String id;
     String dtlnum;
     String partnum;
     String partdesc;
     // getters and setters
}As far as filtering is concerned, regex match would be very easy...
Part[] parts;
Part[] filtered;
//initiallize parts
void filter(String keyword){
     ArrayList<Part> list=new ArrayList<Part>();
     for(Part p:parts){
         if(p.getPartdesc().matches(keyword+".*"))list.add(p);
     filtered=list.toArray();
// call filter function to filter
filter("bath");Thanks!
PS: This code is neither tested nor compiled.

Similar Messages

  • Problem in Graphical message mapping.Need UDF to add array based on some co

    Hi All,
    I have been struck in message mapping.Below i am explaining it,
    I have two input array,
    one array lets call  X [24]
                                    [25]
                                     [26]
                                     [24]
                                    [25]
    other array is Y [10]
                           [11]
                           [12]
                           [13]
                           [14] .length of both the array will be same .
    Now I want the output as: if there is any same value in first array i.e array X then corresponding value of second array should be added.i.e in array X if 24 is coming as twice (1st and 4th) then 1st and 4th value of array Y will be added.So here there will be only three output as Z[23]
                                                      [25]
                                                      [12]
    Please guide me if posiible .I tried to use the for loop but  its not working as the value of X is repeating.
    Regards,
    Saurabh

    Hi,
    Tru this..
    public void test(String[] a,String[] b,ResultList result,Container container){
    int flaga,flagb;
    for(int i=0;i<a.length;i++)
         flaga =0;
         for(int j=i+1;j<a.length;j++)
              int p =  Integer.parseInt(a<i>);
              int q =  Integer.parseInt(a[j]);
              if(p==q)
                   flaga =1;
                   int c = Integer.parseInt(b<i>)+Integer.parseInt(b[j]);
                   String d = new Integer(c).toString();
                   result.addValue (d);
    if (flaga ==0)
    flagb=0;
    for(int q =i-1; q>=0;q--)
         if(Integer.parseInt(a<i>) == Integer.parseInt(a[q]))
              flagb = 1;
    if (flagb == 0) result.addValue((b<i>));
    I have tested with the same input... it is working for me
    http://www.flickr.com/photos/28929439@N06/2721471681/
    Thanks
    SaNv...

  • Displaying contents from UCM based on some criteria

    Hello All,
    I am usin jdev 11.1.1.6
    Depending upon docType
    For ex:
    docType can be cars, bikes, planes
    I want to retrieve from UCM some contents
    For example,
    i want to get ID's TEMP000001, TEMP000002, etc
    then i want to display all contents for that id,
    ID
    Revision
    Folder
    Formats
    TEMP000001
    4
    /Temp1
    TEMP000002
    5
    /Temp2
    Any help is appreciated

    Thank you Vinay.
    Link dealt more with UCM creation.
    Can you give me more details on the query part..."get all docType from UCM.,make a check on docType... and call another services to display"
    I want to know conceptually how its done and a basic code if possible.
    Thank you

  • How to query headers based on some criteria in lines

    Hi,
    I have header table and lines table, header has columns like header_id, customer_id, etc.
    lines table has columns like line_id, header_id, project_id, etc
    Currently i am having queryRN with autoCustomizationCriteria, where I have customer_name (LOV) as search field and provided mapping to customer_id. This is working perfectly fine.
    Now, I want to search all headers where we have alreast one line corresponding to given project.
    I tried writing the code in CO after capturing Go button to setWhereClause and to setWhereClauseParam (i.e. only when project is not null).
    but it is not fetching any headers, even if i don't give any criteria.
    Please help. Preferably I don't want to go for Manual Search.
    is it achievable?
    Thanks,
    Hrishikesh

    Solved it by adding exists clause on lines ...
    I added field in the search panel and added code for Go button in CO to set where clause ..
    Hrishikesh

  • Addition of Node based on some criteria

    Hi Experts,
    My scenario is to add the details of one table of a tab1 to another table of tab2.
    I need to add the details of a Msg_Id of status "High" of the table of tab1 to the table of tab2. I need to check the condition and then add..
    Can any one provide me the code..
    Thanks & Regards,
    Priya

    Try the following
    for(int j=0;j< wdContext.nodeTable1().size();j++)
    String id1= wdContext.nodeTable1().getElementAt(j).getAttributeValue("MsgId");
    // The following will check and add the element to Table2 node
    if(id1.trim().equals("HIGH))
    IPrivate<ViewName>.ITable2Element ele=wdContext.createTable2Element();
    ele.set<<ATTR1>>(wdContext.nodeTable1().getElementAt(j).get<ATTR1>>());
    wdContext.nodeTable2().addElement(ele);
    Regards,Anilkumar
    Message was edited by:
            Anilkumar Vippagunta

  • Assignment of users to groups in portal based on some filter criteria

    Hi All,
    I have some 200 users in portal and the UME is portal database. Now I want to assign 50 users who belong to a specific department to a new group in portal.
    Unfortunately during the assignment of users to groups there is no advanced search option where I can search for the users based on some criteria like department,organisation unit,first name etc. We can only search for the user based on user id or name.
    How can we do a mass assignment of users to groups based on filter?
    Any suggestions / solutions are highly appreciated. Points are rewarded for sure.
    thanks
    Sreeram

    Hi Sreeram,
    three possibilities:
    1.) Develop a small component which does a search based on the criteria you want to use and which then assigns the found users to the group in question. Not really hard, but every development takes some time to develop, some time to test. So if you really want this actione done just once, development may take too long; if the scenario may happen more often, it may make sense to have such a component ready.
    2.) Search for the users based on the criteria you want to use via the portals UI. Copy the result into some wordpad, and assign all results afterwards manually, as you have described. Ugly, but (for a one-time action) faster than 1.).
    3.) Start like 2.), but use the copied result within the wordpad to "import" the group definition via a text file, see http://help.sap.com/saphelp_nw04/helpdata/en/1a/cde2fb82644d98bfb6d558440d6806/frameset.htm and around. Probably the fastest and most efficient way to go!
    Hope it helps
    Detlev

  • Is there an easy way to filter a 2-d array based on the values of two of the fields?

    Is there an easy way to filter a 2-d array based on the values of one of the fields. In my attached VI the output array has the following format:
    TimeStamp        Ident                Frame Type          Bytes    Data
    10:57:07.621   3AD00016   CAN Data Frame   8          0000000000000000
    10:57:07.622   3AD00017   CAN Data Frame   8          000005E000000000
    10:57:07.624   3AD00018   CAN Data Frame   8          0000000003300000
    10:57:07.625   2DC00000   CAN Data Frame   8          0000000000000000
    10:57:07.626   3AD00019   CAN Data Frame    4         0000030000000000
    I would like to delete any rows that do not have an "Ident" between the values of 3AD00000 and 3AD0001E. So for the above data the fourth row would be deleted. The only way I can see to do it is to form a 1-d array. Is there a better approach?
    Thank you.
    Solved!
    Go to Solution.
    Attachments:
    CMM_SN_MULTI.vi ‏20 KB

    Hi chuck72352,
    after you have sorted your data, you can use the InRange Function. Combined with a "search 1D Array" you'll get the range you really want.
    Mike
    Attachments:
    ArraySubset.PNG ‏25 KB

  • Deleting data from a 2D array based on the id of the second column

    Hello
    I hope someone can help me. I have come across a hurdle in the programming of my application.
    1.
    I have a 2D array, the first column of this array contains my data and the second column contains an id, which is either 0 or 1.
    I have sorted this 2D array based on the id column so that the data corresponding to the 0’s is on top part of the array and the data corresponding to the 1’s follows it (on the bottom of the array).
    I want to delete that data (rows) of this sorted array that correspond to the 1’s and keep only the data (rows) that correspond to the 0’s.  
    So I would end up with a new 2D array that has only the data that I want on the first column and 0’s on the second column.
    I have hundreds of these 2D arrays resulting from my program (using a for loop) hence I want to automate this procedure. The length of the selected data arrays will vary.
    2.
    Once I can do this I will want to remove the id column (with the 0’s) from the 2D array and would like to build a new array with only the data from the first column (which may be of different length).
    So I want to end up with a 2D array with columns corresponding to the selected (1st column) data from the (original) 2D arrays. These data may be of different lengths so when building this new array I may need to do some padding. Will labview do this automatically?
    I hope that this is clear.
    Best wishes,

    Attached is a different approach - you don't need to do any sorting.
    The outer FOR loop assumes you have all the arrays available at once. If you are reading a file, modify it accordingly.
    You may or may not want the TRANSPOSE function on the final results, depending on what you want to do with it.
    Yes, when you assemble N-dimensional arrays into (N+1)-dimensional arrays, LabVIEW automatically pads for you.
    Enjoy.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks
    Attachments:
    Extract Marked Data.vi ‏40 KB

  • Oracle and volume- and disk array-based replication?

    Dear mighty all,
    here is a situation:
    Location A - active Oracle database + volume replication software + geocluster software
    Location B - standby location, i.e. standby database + volume replication software + geocluster
    Oracle is 10g
    The size of the database is 500 GB+
    The daily updates are roughly 2-3%.
    The comm channel between locations can have any reasonable bandwidth, however the jitter and latency cannot be guaranteed (i.e. no synchronous replication).
    This is a matter of protecting against a disaster (such as a complete destruction of Location A).
    The task is to make sure that Location B has the up-to-date data (RPO is 8 hours) and Oracle database can be started automatcially without any manual intervention. (I.e. cluster administrator pushes the button and the rest is done without human intervention).
    Here is what I am thinking of:
    1) volume replication software usually observes the atomicity on the disk block level. I.e. it is impossible that the data block being updated on the volume in Location A is updated in location B incompletely.
    2) When the database in Location A completes a transaction it writes data to the disk thus initiating the series of disk block updates being sent to Location B.
    3) From the database point of view, the transaction is completed, database files are updated.
    4) However there is a slim chance of Location A being destroyed while:
    * the volume replication software has started pushing through to Location B the updated disk blocks representing the completed transaction
    * but it did not finish transmitting the whole lot of disk updates (boom! the asteroid fell on Location A)
    * and volume replicator in Location B cannot roll back the disk updates since volume replicator does not know of the database transaction
    5) Volume replicator atomicity is disk data block while Oracle's atomictity is transaction (i.e. there cannot be a half-transaction applied)
    6) Thus, when we start Oracle in Location B, we will get inconsistent database, since the last transaction was transferred to Location B incompletely
    7) Sure that there is a way to fix this using various DBA tools, but that defies the whole purpose of automatic start
    So, my question is:
    1) Is volume- or disk array-based replication not a good idea in this case at all?
    2) or is there a way to nonetheless ensure the consistency of the database (say start it every time in the recovery mode)?
    3) Or should I dump the idea of replicating Oracle with volume replication and switch to DataGuard? (The cluster software can handle DataGuard).
    thanks a million for your answers, ye mighty all!

    Hi,
    this is not a "typical" question what is easy to discuss in a forum.
    Just some hints:
    1. using volume replication won't help you against logical or physical corruption
    2. RPO of 8 hours ? Sounds a lot regarding a change rate of 10-15 GB a day.
    3. 100% Automation is normally not a good idea in a database disaster scenario
    ( a false disaster detection can end in a real disaster!) I've already seen too much databases which had been totally corrupted by a false switch.

  • Get value from the array based on the HashCode

    public static void runJoin(int[][] t1,int[][] t2)
         PrintWriter out=null;
         int rows = 1000;
         int cols = 7;
         int [][] myTable3 = new int[rows][cols];
         int x = 0;
         System.out.print("Running HashJoin:Method loads the "+
         "smaller table in the memory and applies a hashing function "+
         "to common column and stores it in another table. "+
         "The larger table is then read from the file. "+
         "The same hashing function is applied to Col n of the table and a       matching record in the first table is looked up. A match will create a row in Table 3. ");          
    //Apply hashing function to smaller table and store it in the memory.
              Integer[] It2 = new Integer[t2.length];
              int [] hashCodest2 = new int[t2.length];
              Hashtable ht = new Hashtable();
              for(int i =0; i <t2.length;i++){
                   It2[i] = new Integer(t2[0]);
                   hashCodest2[i] = It2[i].hashCode();
                   ht.put(new Integer(hashCodest2[i]),It2[i]);
              //Larger table get hashcodes
              Integer It1[] = new Integer[t2.length];
              int [] hashCodest1 = new int[t2.length];          
              for(int j =0; j <t1.length;j++){
                   It1[j] = new Integer(t1[j][4]);
                   hashCodest1[j] = It1[j].hashCode();               }
              //Based on the hashcode get the value from the Table2;
              try{
    out = new PrintWriter( new FileOutputStream( "c:\\HashJoinTable.txt" ) );
              Enumeration e = ht.keys();
                   while(e.hasMoreElements())
    //How do I get the value from the array based on the HashCode? Do I need to do a loop here???                         
    hashCodes1.get(e.nextElement());           
              }catch(Exception e){}

    ok I got it......
              //Apply hashing function to smaller table and store it in the memory.
              Integer[] It2 = new Integer[t2.length];
              int [] hashCodest2 = new int[t2.length];
              Hashtable ht = new Hashtable();
              for(int i =0; i <t2.length;i++){
                   It2[i] = new Integer(t2[0]);
                   hashCodest2[i] = It2[i].hashCode();
                   ht.put(new Integer(hashCodest2[i]),It2[i]);
              //Larger table get hashcodes and compare
              Integer It1[] = new Integer[t2.length];
              int [] hashCodest1 = new int[t2.length];          
              Hashtable ht2 = new Hashtable();
              for(int j =0; j <t1.length;j++){
                   It1[j] = new Integer(t1[j][4]);
                   hashCodest1[j] = It1[j].hashCode();               
                   ht2.put(new Integer(hashCodest1[j]),It1[j]);
              //Based on the hashcode get the value from the Table2;
              try{
    out = new PrintWriter( new FileOutputStream( "c:\\HashJoinTable.txt" ) );
              Enumeration e = ht.keys();
              Integer t3[] = new Integer[t2.length];
                   while(e.hasMoreElements())
                        t3[x] = (Integer) ht2.get(e.nextElement());                
                        x++;
              }catch(Exception e){}

  • How to add byte[] array based Image to the SQL Server without using parameter

    how to add byte[] array based Image to the SQL Server without using parameter.I have a column in table with the type image in sql and i want to add image array to the sql image column like below:
    I want to add image (RESIM) to the procedur like shown above but sql accepts byte[] RESIMI like System.Drowing. I whant that  sql accepts byte [] array like sql  image type
    not using cmd.ParametersAdd() method
    here is Isle() method content

    SQL Server binary constants use a hexadecimal format:
    https://msdn.microsoft.com/en-us/library/ms179899.aspx
    You'll have to build that string from a byte array yourself:
    byte[] bytes = ...
    StringBuilder builder = new StringBuilder("0x", 2 + bytes.Length * 2);
    foreach (var b in bytes)
    builder.Append(b.ToString("X2"));
    string binhex = builder.ToString();
    That said, what you're trying to do - not using parameters - is the wrong thing to do. Not only it is insecure due to the risk of SQL injection but in the case of binary data is also inefficient since these hex strings are larger than the original byte[]
    data.

  • Sorting an array based on the value of another array

    Hi
    Ive got 2 arrys... An Integer[]{11,12,23,24,25};
    and another one double[]{60,79,83,54,67};
    i wanna sort the first array based on the values of the second array..
    ie my result should be double[]{83,79,67,60,54} and
    Integer[]={23,12,25,11,24}...........
    is thr any easy method to do tis..

    You should make a class with the int and the double as fields; and have your class implement Comparable to compare on the double the way you want; and just have an array of objects of this class, and sort it.
    Because the corresponding elements in your arrays are essentially linked, so they should be together.
    Edited by: spoon_ on Apr 12, 2008 2:17 AM

  • How to Filter Key Figures in Columns Based on a Selection

    Hello,
    I am trying to get my columns to dynamically filter based on some selection and would like to know what is the easiest way to make this happen.  My scenario involves displaying 12 months of data for an actual / budget view.  So we may need 8 months of actuals and 4 months of plan, 9 months of actuals and 3 months of plan, 10 months of actuals and 2 months of plan, etc.  The row is cost element and my columns are restricted key figures.  I want the user to be able to easily select an 8/4 look and the dynamically remove the unnecessary columns.  Same with a 9/3 or a 10/2.  Besides these 12 months of Act / Bud, I have 12 months of plan, 12 months of actuals for other years, so I have lots of key figures.  Just doing the basic filter can be too cumbersome.
    Thanks,
    Cherie

    Hi Cherie,
    This is exactly the type of problem that I'm currently trying to figure out. I'm trying to following your solution but I'm not clear on how you actually achieved this in you last note. I want to dynamically select actuals/budget column fields based on what period I enter. I thought about creating 12 separate RKF fields for actuals and 12 separate RKF fields for the budget reforecast and outputting these all and then doing some VBA to hide the fields not required based on which period was selected... how is your variable ZFYAPER7 defined and calculated?
    Cheers

  • R12: How to filter Open Item Revaluation Report based on GL Date

    Hi,
    Anybody know how to filter Open Item Revaluation Report based on GL Date from and GL Date to in R12?
    Since we just upgraded from 11.5.10 to 12.1.3 and found we cannot filter those report for specific date. It shown all data included the old data from 8 years ago also.
    We need to run the report only for specific date only. Please share with me if anyone know about this.
    Thanks.

    Pl do not post duplicates - R12: How to filter Open Item Revaluation Report based on GL Date

  • How to filter the Rest Api data based on Taxanomy columns

    Hi Everyone,
    We are using SharePoint2010 Standard Edition.
    I wanted get the library details through REST Api. I am using as below:
    https://SiteUrl/_vti_bin/listdata.svc/Documents?$filter=Title eq 'SharePointDoc'
    Here I am able to get the info regarding "SharePointDoc". But when I am trying to get the details from Taxonomy filter, it didn't.
    Can anyone please tell me how can we filter based on Taxanomy fields.
    Thanks in Advance
    Krishnasandeep

    Hi,
    I understand that you wanted to filter the Rest Api data based on Taxanomy columns.
    Per my knowledge, in SharePoint 2010 , not all types of column are available via REST, most annoyingly managed metadata columns are amongst this group of unsupported column types.
    However, in SharePoint 2013, we can filter list items based on taxonomy (managed metadata) columns.
    Taxonomy fields can be now called via REST API using CAML query in REST calls.
    Here is a great blog for your reference:
    http://www.cleverworkarounds.com/2013/09/23/how-to-filter-on-a-managed-metadata-column-via-rest-in-sharepoint-2013/comment-page-1/
    You’d better to change the REST calls and the CAML query to check whether it works in SharePoint 2010.
    More information:
    http://platinumdogs.me/2013/03/14/sharepoint-adventures-with-the-rest-api-part-1/
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

Maybe you are looking for