Searching for discontinuity in an array of timestamps

Hi,
I have a problem with an array of timestamps.
I wish to search the array for discontinuous times. i.e. there should be a time each minute and I wish to be able to seperate the data into differant arrays according to these discontinuities.
i.e. if I have a time of 13:00 then 13:01, 16:05,16:06   I want the first two to go into one array and the second two to go into another array etc......
Please help

Having not seen your vi i dont know if it suitable for your purpose, however have you thought about using the "Get Date / Time String" vi from the timing pallette and using that instead?  If the time stamps are created from a measurement then you should be able to do as Lyn and Gerd have suggested above.  If not try this vi i have attached which simple takes the mins and hours out of the time stamp.
Craig
Message Edited by craigc on 03-23-2007 11:47 AM
LabVIEW 2012
Attachments:
test2.vi ‏10 KB

Similar Messages

  • How to search for particular string in array?

    I am struggling to figure out how to search array contents for a string and then delete the entry from the array if it is found.
    The code for a program that allows the user to enter up to 20 inventory items (tools) is posted below; I apologize in advance for it as I am also not having much success grasping the concept of OOP and I am certain it is does not conform although it all compiles.
    Anyway, if you can provide some assistance as to how to go about searching the array I would be most grateful. Many thanks in advance..
    // ==========================================================
    // Tool class
    // Reads user input from keyboard and writes to text file a list of entered
    // inventory items (tools)
    // ==========================================================
    import java.io.*;
    import java.text.DecimalFormat;
    public class Tool
    private String name;
    private double totalCost;
    int units;
      // int record;
       double price;
    // Constructor for Tool
    public Tool(String toolName, int unitQty, double costPrice)
          name  = toolName;
          units = unitQty;
          price = costPrice;
       public static void main( String args[] ) throws Exception
          String file = "test.txt";
          String input;
          String item;
          String addItem;
          int choice = 0;
          int recordNum = 1;
          int qty;
          double price;
          boolean valid;
          String toolName = "";
          String itemQty = "";
          String itemCost = "";
          DecimalFormat fmt = new DecimalFormat("##0.00");
          // Display menu options
          System.out.println();
          System.out.println(" 1. ENTER item(s) into inventory");
          System.out.println(" 2. DELETE item(s) from inventory");
          System.out.println(" 3. DISPLAY item(s) in inventory");
          System.out.println();
          System.out.println(" 9. QUIT program");
          System.out.println();
          System.out.println("==================================================");
          System.out.println();
          // Declare and initialize keyboard input stream
          BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
          do
             valid = false;
             try
                System.out.print(" Enter an option > ");
                input = stdin.readLine();
                choice = Integer.parseInt(input);
                System.out.println();
                valid = true;
             catch(NumberFormatException exception)
                System.out.println();
                System.out.println(" Only numbers accepted. Try again.");
          while (!valid);
          while (choice != 1 && choice != 2 && choice != 9)
                System.out.println(" Not a valid option. Try again.");
                System.out.print(" Enter an option > ");
                input = stdin.readLine();
                choice = Integer.parseInt(input);
                System.out.println();
          if (choice == 1)
             // Declare and initialize input file
             FileWriter fileName = new FileWriter(file);
             BufferedWriter bufferedWriter = new BufferedWriter(fileName);
             PrintWriter dataFile = new PrintWriter(bufferedWriter);
             do
                addItem="Y";
                   System.out.print(" Enter item #" + recordNum + " name > ");
                   toolName = stdin.readLine();
                   if (toolName.length() > 15)
                      toolName = toolName.substring(0,15); // Convert to uppercase
                   toolName = toolName.toUpperCase();
                   dataFile.print (toolName + "\t");
                   do
                      valid = false;
                      try
                         // Prompt for item quantity
                         System.out.print(" Enter item #" + recordNum + " quantity > ");
                         itemQty = stdin.readLine();
                         // Parse integer as string
                         qty = Integer.parseInt (itemQty);
                         // Write item quantity to data file
                         dataFile.print(itemQty + "\t");
                         valid=true;
                      catch(NumberFormatException exception)
                         // Throw error for all non-integer input
                         System.out.println();
                         System.out.println(" Only whole numbers please. Try again.");
                   while (!valid);
                   do
                      valid = false;
                      try
                         // Prompt for item cost
                         System.out.print(" Enter item #" + recordNum + " cost (A$) > ");
                         itemCost = stdin.readLine();
                         // Parse float as string
                         price = Double.parseDouble(itemCost);
                         // Write item cost to data file
                         dataFile.println(fmt.format(price));
                         valid = true;
                      catch(NumberFormatException exception)
                         // Throw error for all non-number input (integers
                      // allowed)
                         System.out.println();
                         System.out.println(" Only numbers please. Try again.");
                   while (!valid);
                   // Prompt to add another item
                   System.out.println();
                   System.out.print(" Add another item? Y/N > ");
                   addItem = stdin.readLine();
                   while ((!addItem.equalsIgnoreCase("Y")) && (!addItem.equalsIgnoreCase("N")))
                      // Prompt for valid input if not Y or N
                      System.out.println();
                      System.out.println(" Not a valid option. Try again.");
                      System.out.print(" Add another item? Y/N > ");
                      addItem = stdin.readLine();
                      System.out.println();
                   // Increment record number by 1
                   recordNum++;
                   if (addItem.equalsIgnoreCase("N"))
                      System.out.println();
                      System.out.println(" The output file \"" + file + "\" has been saved.");
                      System.out.println();
                      System.out.println(" Quitting program.");
            while (addItem.equalsIgnoreCase("Y"));
    // Close input file
    dataFile.close();
       if (choice == 2)
       try {
          Read user input (array search string)
          Search array
          If match found, remove entry from array
          Confirm "deletion" and display new array contents
       catch block {
    } // class
    // ==========================================================
    // ListToolDetails class
    // Reads a text file into an array and displays contents as an inventory list
    // ==========================================================
    import java.io.*;
    import java.util.StringTokenizer;
    import java.text.DecimalFormat;
    public class ListToolDetails {
       // Declare variable
       private Tool[] toolArray; // Reference to an array of objects of type Tool
       private int toolCount;
       public static void main(String args[]) throws Exception {
          String line, name, file = "test.txt";
          int units, count = 0, record = 1;
          double price, total = 0;
          DecimalFormat fmt = new DecimalFormat("##0.00");
          final int MAX = 20;
          Tool[] items = new Tool[MAX];
          System.out.println("Inventory List");
          System.out.println();
          System.out.println("REC.#" + "\t" + "ITEM" + "\t" + "QTY" + "\t"
                + "PRICE" + "\t" + "TOTAL");
          System.out.println("\t" + "\t" + "\t" + "\t" + "PRICE");
          System.out.println();
          try {
             // Read a tab-delimited text file of inventory items
             FileReader fr = new FileReader(file);
             BufferedReader inFile = new BufferedReader(fr);
             StringTokenizer tokenizer;
             while ((line = inFile.readLine()) != null) {
                tokenizer = new StringTokenizer(line, "\t");
                name = tokenizer.nextToken();
                try {
                   units = Integer.parseInt(tokenizer.nextToken());
                   price = Double.parseDouble(tokenizer.nextToken());
                   items[count++] = new Tool(name, units, price);
                   total = units * price;
                } catch (NumberFormatException exception) {
                   System.out.println("Error in input. Line ignored:");
                   System.out.println(line);
                System.out.print(" " + count + "\t");
                System.out.print(line + "\t");
                System.out.print(fmt.format(total));
                System.out.println();
             inFile.close();
          } catch (FileNotFoundException exception) {
             System.out.println("The file " + file + " was not found.");
          } catch (IOException exception) {
             System.out.println(exception);
          System.out.println();
       //  Unfinished functionality for displaying "error" message if user tries to
       //  add more than 20 tools to inventory
       public void addTool(Tool maxtools) {
          if (toolCount < toolArray.length) {
             toolArray[toolCount] = maxtools;
             toolCount += 1;
          } else {
             System.out.print("Inventory is full. Cannot add new tools.");
       // This should search inventory by string and remove/overwrite matching
       // entry with null
       public Tool getTool(int index) {
          if (index < toolCount) {
             return toolArray[index];
          } else {
             System.out
                   .println("That tool does not exist at this index location.");
             return null;
    }  // classData file contents:
    TOOL 1     1     1.21
    TOOL 2     8     3.85
    TOOL 3     35     6.92

    Ok, so you have an array of Strings. And if the string you are searching for is in the array, you need to remove it from the array.
    Is that right?
    Can you use an ArrayList<String> instead of a String[ ]?
    To find it, you would just do:
    for (String item : myArray){
       if (item.equals(searchString){
          // remove the element. Not trivial for arrays, very easy for ArrayList
    }Heck, with an arraylist you might be able to do the following:
    arrayList.remove(arrayList.indexOf(searchString));[edit]
    the above assumes you are using 1.5
    uses generics and for each loop
    [edit2]
    and kinda won't work it you have to use an array since you will need the array index to be able to remove it. See the previous post for that, then set the value in that array index to null.
    Message was edited by:
    BaltimoreJohn

  • Search for a subarray in array

    Hi!
    Is there a VI or a simple way to search for a subarray in array and to get the index of the subarray? The same thing does DTbl Search for Digital Pattern.vi with digital data and Search 1D Array.vi searches for just one element in the array.
    Thank you!
    Solved!
    Go to Solution.

    Playing around with Gerd's idea of using the search 1D Array, I came up with this.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Find Subarray.png ‏16 KB

  • PHP Search for rows given an array of ID's

    Given an arbitrarily large array of ID's, I want to search an Oracle table for each row based on the ID's in said array and return the results. I can't find a decent way to do this, however, as the array can contain thousands upon thousands of ID's. Obviously, "WHERE IN ()" would not work, as the array can be much larger than 1000.
    Initially, I tried to insert all of the ID's into a global temporary table to do an inner join against but I cannot seem to get this to work. I believe the size of the query gets too large? I have been banging my head against the wall on this for a while and all I can find online is the solutions that work for inserting only a relatively small number of rows, "INSERT ALL" for example.
    I can't be the first person in the world who has needed to do a search based on an array of ID's. Can anyone help me?

    I attempted it using 50 ID's using the following syntax:
    $sql = "INSERT ALL";
    foreach ($entityIdList as $entityId)
    $sql .= " INTO TEMP_ENTITY_TABLE (ENTITY_ID) VALUES ('{$entityId}')";
    $sql .= " SELECT 1 FROM DUAL";
    I run this code and get no errors but when I try to fetch the results by using fetchAll("SELECT * FROM TEMP_ENTITY_TABLE") I just get an empty array returned.
    I thought maybe this was due to the rows being deleted prior to the select executing (I did not specify "PRESERVE ROWS" I will note) so I attempted the query in SQLPlus to see what was happening. It was SQLPlus that told me my query was too long (>2499 characters) and failed out. I thought perhaps the query in code was also getting way too long to be an efficient means of inserting the rows.
    Also, the results of the query you posted are:
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE 11.2.0.3.0 Production
    TNS for Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production

  • Search for Duplicates in a 2D Array

    I am working on a program that takes a user input of a job number (imported as a string).
    With that job number I need to search a .txt spreadsheet file for the job number and create a cluster of information based on the items in the same row as the job number. I originally accomplished this as shown:
    This worked very well. That is, until my data file changed. Now my data file can possibly have a duplicate item as attached. The only difference between the two rows is that the second column has a smaller value. I cannot change how I receive my data. I always need to return the row that has the larger value in the second column.
    The method I came up with is as shown:
    This method seems to be a lot less efficient than the original method since it requires that even if the job number is the first item on the list, I must step through the entire list. The file I am working with is computer generated, so it will always be sorted by job number, but we cannot guarantee whether the first or the second or the third occurance of the item is going to be the longest.
    Any thoughts on a more efficient method of handling this? I searched around and saw a posting that used variant data types to remove duplicate values from a 2D array. I tried to expand that to this application, but I wasn't able to follow the use of variants in that situation. This is the original posting I saw: http://forums.ni.com/t5/LabVIEW/Remove-Duplicate-R​ow-From-2d-Array/m-p/1211071/highlight/false#M5186​...
    Thanks,
    Michael
    Attachments:
    nchcablejobs.txt ‏49 KB

    here is one way to find all matches first and then you can add a fine search/separation if there is more than one match
    depending on the size of the sorted array it might be faster if you search for the first match and than look if the next still matches ...
    Greetings from Germany
    Henrik
    LV since v3.1
    “ground” is a convenient fantasy
    '˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'
    Attachments:
    find all matches.vi ‏11 KB

  • Search for a regular expression in a 1D array?

    I've got a 1D array of strings, and I want to find the row with "Date: yy/mm/dd" in it. Since yy/mm/dd would not necessarily be the same between runs, I can't look for the row with "Date: yy/mm/dd".
    I tried using the Search 1D Array with "Date: " and "Date: *" as my element input, but it didn't find either of 'em.
    I don't know where in vi.lib the function would be in, otherwise I'd attempt to mod the function to take regular expressions, and my off-the-cuff search attempt (looping through the array & using Match Regular Expression) had some odd errors and still didn't find the row.
    Thanks!

    What do you define as a "row"? Is each row a single array element? Since your array elements are strings, each array element itself could be a multiline|multirow string itself that might need to be analyzed one row at a time.
    To look for patterns:
    If you have LabVIEW 8.0 or higher, you can use "Match regular expression". Else you can use "Match Pattern". It really depends how specific you need to be. Are there lines that start with "Date:" but don't contain a formatted date afterwards?
    To search for array elements starting with simple string "Date:", use "match first string".
    LabVIEW Champion . Do more with less code and in less time .

  • How to search for array in another array ?

    i want to search for array in another and when i got this array i want to take the next 5 bits  EX: array1 [ 4 8 7] , array2 [ 9 1 4 8 7 6 3 2 ] , output array [ 6 3 2 9 1]
    Thanks  

    I know we should be encouraging others to help them selves, but I had a solution that I think is what the user wants.  Attached is a VI that searches for a subarray in an array, and will return the index it is found at.  It will also return the input array, filtered if a match is found.  This VI just handles the double data type.
    Most of the code comes from an old post by Altenbach that I can't seem to find at the moment, but I saved a copy a while ago.  Props to him for posting it.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.
    Attachments:
    Filter Subarray - DBL.vi ‏18 KB

  • Search for Emails and place them on a array

    I have the following asp/vbscript code that search for the
    content of a folder with text files. I need someone to help me out
    to modify the code to automatically search for email addresses on
    each text file and place them on an array.

    Passwords are stored in the password files (encrypted).
    Bookmarks are stored in the bookmarks file.
    These can't get your data back, but will help in the future.
    These add-ons can be a great help by backing up and restoring Firefox
    '''[https://addons.mozilla.org/en-US/firefox/addon/febe/ FEBE (Firefox Environment Backup Extension)]''' {web link}
    FEBE allows you to quickly and easily backup your
    Firefox extensions, history, passwords, and more.
    In fact, it goes beyond just backing up -- It will actually rebuild
    your saved files individually into installable .xpi files.
    It will also make backup of files that you choose.
    '''[https://addons.mozilla.org/en-US/firefox/addon/opie/ OPIE]''' {web link}
    Import/Export extension preferences

  • Neen help with date range searches for Table Sources

    Hi all,
    I need help, please. I am trying to satisfy a Level 1 client requirement for the ability to search for records in crawled table sources by a date and/or date range. I have performed the following steps, and did not get accurate results from Advanced searching for date. Please help me understand what I am doing wrong, and/or if there is a way to define a date search attribute without creating a LOV for a date column. (My tables have 500,00 rows.)
    I am using SES 10.1.8.3 on Windows 32.
    My Oracle 10g Spatial Table is called REPORTS and this table has the following columns:
    TRACKNUM Varchar2
    TITLE Varchar2
    SUMMARY CLOB
    SYMBOLCODE Varchar2
    Timestamp Date
    OBSDATE Date
    GEOM SDO_GEOMETRY
    I set up the REPORTS table source in SES, using TRACKNUM as the Primary Key (unique and not null), and SUMMARY as the CONTENT Column. In the Table Column Mappings I defined TITLE as String and TITLE.
    Under Global Settings > Search Attributes I defined a new Search Attribute (type Date) called DATE OCCURRED (DD-MON-YY).
    Went back to REPORTS source previously defined and added a new Table Column Mapping - mapping OBSDATE to the newly defined DATE OCCURRED (DD-MON-YY) search attribute.
    I then modified the Schedule for the REPORTS source Crawler Policy to “Process All Documents”.
    Schedule crawls and indexes entire REPORTS table.
    In SES Advanced Search page, I enter my search keyword, select Specific Source Group as REPORTS, select All Match, and used the pick list to select the DATE OCCURRED (DD-MON-YY) Attribute Name, operator of Greater than equal, and entered the Value 01-JAN-07. Then the second attribute name of DATE_OCCURRED (DD-MON-YY), less than equals, 10-JAN-07.
    Search results gave me 38,000 documents, and the first 25 I looked at had dates NOT within the 01-JAN-07 / 10-JAN-07 range. (e.g. OBSDATE= 24-MAR-07, 22-SEP-), 02-FEB-08, etc.)
    And, none of the results I opened had ANY dates within the SUMMARY CLOB…in case that’s what was being found in the search.
    Can someone help me figure out how to allow my client to search for specific dated records in a db table using a single column for the date? This is a major requirement and they are anxiously awaiting my solution.
    Thanks, in advance….

    raford,
    Thanks very much for your reply. However, from what I've read in the SES Admin Document is that (I think) the date format DD/MM/YYYY pertains only to searches on "file system" sources (e.g. Word, Excel, Powerpoint, PDF, etc.). We have 3 file system sources among our 25 total sources. The remaining 22 sources are all TABLE or DATABASE sources. The DBA here has done a great job getting the data standardized using the typical/default Oracle DATE type format in our TABLE sources (DD-MON-YY). Our tables have anywhere from 1500 rows to 2 million rows.
    I tested your theory that the dates we are entering are being changed to Strings behind the scenes and on the Advanced Page, searched for results using OBSDATE equals 01/02/2007 in an attempt to find data that I know for certain to be in the mapped OBSDATE table column as 01-FEB-07. My result set contained data that had an OBSDATE of 03-MAR-07 and none containing 01-FEB-07.
    Here is the big issue...in order for my client to fulfill his primary mission, one of the top 5 requirements is that he/she be able to find specific table rows that are contain a specific date or range of dates.
    thanks very much!

  • Need help with date range searches for Table Sources in SES

    Hi all,
    I need help, please. I am trying to satisfy a Level 1 client requirement for the ability to search for records in crawled table sources by a date and/or date range. I have performed the following steps, and did not get accurate results from Advanced searching for date. Please help me understand what I am doing wrong, and/or if there is a way to define a date search attribute without creating a LOV for a date column. (My tables have 500,00 rows.)
    I am using SES 10.1.8.3 on Windows 32.
    My Oracle 10g Spatial Table is called REPORTS and this table has the following columns:
    TRACKNUM Varchar2
    TITLE Varchar2
    SUMMARY CLOB
    SYMBOLCODE Varchar2
    Timestamp Date
    OBSDATE Date
    GEOM SDO_GEOMETRY
    I set up the REPORTS table source in SES, using TRACKNUM as the Primary Key (unique and not null), and SUMMARY as the CONTENT Column. In the Table Column Mappings I defined TITLE as String and TITLE.
    Under Global Settings > Search Attributes I defined a new Search Attribute (type Date) called DATE OCCURRED (DD-MON-YY).
    Went back to REPORTS source previously defined and added a new Table Column Mapping - mapping OBSDATE to the newly defined DATE OCCURRED (DD-MON-YY) search attribute.
    I then modified the Schedule for the REPORTS source Crawler Policy to “Process All Documents”.
    Schedule crawls and indexes entire REPORTS table.
    In SES Advanced Search page, I enter my search keyword, select Specific Source Group as REPORTS, select All Match, and used the pick list to select the DATE OCCURRED (DD-MON-YY) Attribute Name, operator of Greater than equal, and entered the Value 01-JAN-07. Then the second attribute name of DATE_OCCURRED (DD-MON-YY), less than equals, 10-JAN-07.
    Search results gave me 38,000 documents, and the first 25 I looked at had dates NOT within the 01-JAN-07 / 10-JAN-07 range. (e.g. OBSDATE= 10-MAR-07, 22-SEP-07, 02-FEB-08, etc.)
    And, none of the results I opened had ANY dates within the SUMMARY CLOB…in case that’s what was being found in the search.
    Can someone help me figure out how to allow my client to search for specific dated records in a db table using a single column for the date? This is a major requirement and they are anxiously awaiting my solution.
    Thanks very much, in advance….

    raford,
    Thanks very much for your reply. However, from what I've read in the SES Admin Document is that (I think) the date format DD/MM/YYYY pertains only to searches on "file system" sources (e.g. Word, Excel, Powerpoint, PDF, etc.). We have 3 file system sources among our 25 total sources. The remaining 22 sources are all TABLE or DATABASE sources. The DBA here has done a great job getting the data standardized using the typical/default Oracle DATE type format in our TABLE sources (DD-MON-YY). Our tables have anywhere from 1500 rows to 2 million rows.
    I tested your theory that the dates we are entering are being changed to Strings behind the scenes and on the Advanced Page, searched for results using OBSDATE equals 01/02/2007 in an attempt to find data that I know for certain to be in the mapped OBSDATE table column as 01-FEB-07. My result set contained data that had an OBSDATE of 03-MAR-07 and none containing 01-FEB-07.
    Here is the big issue...in order for my client to fulfill his primary mission, one of the top 5 requirements is that he/she be able to find specific table rows that are contain a specific date or range of dates.
    thanks very much!

  • Searching for strings in a txt file

    I am writing a program based on the six degrees of seperation theory.
    Basically I have been given a (very large) txt file from the imdb with a list of all the films written in it.
    The text in the document is written like this:
    'Tis Autumn: The Search for Jackie Paris (2006)/Paris, Jackie/Moody, James (IV)/Bogdanovich, Peter/Vera, Billy/Ellison, Harlan/Newman, Barry/Whaley, Frank/Murphy, Mark (X)/Tosches, Nick (I)/Moss, Anne Marie
    (Desire) (2006)/Ruggieri, Elio/Micijevic, Irena
    .45 (2006)/Dorff, Stephen/Laresca, Vincent/Eddis, Tim/Bergschneider, Conrad/Campbell, Shawn (II)/Macfadyen, Angus/John, Suresh/Munch, Tony/Tyler, Aisha/Augustson, Nola/Greenhalgh, Dawn/Strange, Sarah/Jovovich, Milla/Hawtrey, Kay
    10 Items or Less (2006)/Ruiz, Hector Atreyu/Torres, Emiliano (II)/Parsons, Jim (II)/Freeman, Morgan (I)/Pallana, Kumar/Cannavale, Bobby/Nam, Leonardo/Hill, Jonah/Vega, Paz/Echols, Jennifer/Dudek, Anne/Berardi, Alexandra
    10 MPH (2006)/Weeks, Hunter/Armstrong, Pat (II)/Caldwell, Josh/Waisman, Alon/Keough, Johnathan F./Weeks, Gannon
    10 Tricks (2006)/Cruz, Raymond/Swetland, Paul/Selznick, Albie/Hennings, Sam/Gleason, Richard/Leake, Damien/Skipp, Beth/Ishibashi, Brittany/Thompson, Lea (I)/Jinaro, Jossara/Brink, Molly
    1001 Nights (2006)/Wright, Jeffrey (I)
    10th & Wolf (2006)/Lee, Tommy (VI)/Renfro, Brad/Ligato, Johnny/De Laurentiis, Igor/Luke Jr., Tony/Mihok, Dash/Garito, Ken/Capodice, John/Dennehy, Brian/Gullion, Jesse/Salvi, Francesco (I)/Cordek, Frank/Marsden, James (I)/Bernard, Aaron/Brennan, Patrick (VII)/O'Rourke, Ben/Gallo, Billy/Heaphy, James/Stragand, Dave/Vellozzi, Sonny/Pistone, Joe (I)/Morse, David (III)/Landis, Pete/Cain, Atticus/Trevelino, Dan/Demme, Larry/Sisto, Frank/Rosenbaum, Paul/Grimaldi, James (I)/Ribisi, Giovanni/Hopper, Dennis/Devon, Tony/Sigismondi, Barry/Kilmer, Val/Marinelli, Sonny/Cacia, Joseph/Rossi, Leo (II)/Tott, Jeffrey/Wawrzyniak, Aaron/Boombotze, Joey/Marie, Corina/Arvie, Michilline/Warren, Lesley Ann/De Laurentiis, Veronica/Moresco, Amanda/Boecker, Margot/Rossi, Rose/Latimore, Meritt/Dunlap, Doreen/Perabo, Piper/Horrell, Nickole/Sonnichsen, Ingrid
    11 Minutes Ago (2006)/Irving, Len/Welzbacher, Craig/Michaels, Ian/Dahl, Evan Lee/Gebert, Bob/Juuso, Jeremy/Hope, Trip/Green-Gaber, Renata/Dawn, Turiya/Reneau, Taryn/M
    Thats just 2 lines!
    what the program will do is take in a name (from a gui) of an actor/actress and find the smallest connection to a famous actor.
    So first things first, my idea of thinking is to search the file for K.E.V.I.N. B.A.C.O.N and all his films, and safe them into an array. Then do another search for films from the actor that the user entered at the gui. then find the shortest possible connection to both stars.
    my code for the search part of the program
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.File;
    import java.io.FileNotFoundException;
    public class FileSearch {
         File aFile = new File("cast.06.txt");     
         FileInputStream inFile = null;
         String actor = "surname, forename"; // the person who will be the centre point e.g. kevin.bacon.
           //get the result of the actor from the gui will go here.
         public void openFilm()
              try
                  inFile = new FileInputStream(aFile);     
              catch(FileNotFoundException e)
                   System.out.println("Error");
    }The problem I have is that I can't work out how to search the txt file for a specific string/s and save them into an array. (I'm not sure if this is the best way to go about it or not at this stage).
    So whats the best way to search for an actor from that file and save the film title and the year of release?
    Hope this makes sense? what I hope the final program will be like is like this http://oracleofbacon.org/

    I went away and looked at regular expressions and this is what I came up with
    public class NameSearch{
         public static void main(String[] args)
              NameSearch ns = new NameSearch();
              ns.runIt();
         public void runIt()
              java.util.Scanner fileScan = null;
              try{
                   fileScan = new java.util.Scanner(new java.io.File("imdb.txt"));
              }catch(java.io.FileNotFoundException e)
                   e.printStackTrace();
                   System.exit(0);
              String token = null;
              String actor = "Surname, Forename";
    //real name will go in actor, left it like that for example
              while(fileScan.hasNext()){
                   token = fileScan.next();
                   Pattern pattern = Pattern.compile(actor);
                   Matcher m = pattern.matcher(token);
                   while(m.find())
                        System.out.println(m.start() + m.end());
    }This by any means not finished, I'm just trying to get to grips with regualr expressions. But when I run the program it doesn't return anything, from what I've tried to work out is it should return actor x amount of times they appear in the file. But when I run it nothing comes back (the actors name is in the text file) so I'm not too sure what I'm doing wrong, any suggestion please

  • [CS3 JS] How to search for accented letters with GREP

    Hello,
    In the following script I have two words, each that has an accented letter. It appears that neither in the script nor in the Find and Replace dialog that GREP will recognize words with accents. It will replace accented characters however. I can do a search for words with no accents but that will lead to trouble when I only want to change the word if it has an accent.
    Any advice would be great!
    Tom
    var myDoc = app.activeDocument;
    var rawWordsAccented = ["André","Barrës"]; //find these words
    var rawWordsAccentedDHyphens = ["~-Andr\\x{00E9}","~-Barr\\x{00EB}s"]; //replacement words
    for(var k =0; rawWordsAccented.length > k; k++){
        var numWords = theGrepChanger(myDoc,rawWordsAccented[k],rawWordsAccentedDHyphens[k]);   
        }//end for k
    function theGrepChanger(docRef,grepFindIt,grepChangeIt){
        app.findGrepPreferences = NothingEnum.NOTHING;
        app.changeGrepPreferences = NothingEnum.NOTHING;
        app.findGrepPreferences.findWhat = grepFindIt;
        app.changeGrepPreferences.changeTo = grepChangeIt;
        var arrGrepFindIt = myDoc.changeGrep();
        return arrGrepFindIt;
    }//end theGrepFinder

    John, perhaps it works in CS5 but not in CS3.
    Peter, the problem is not in the replacement word or looping through that array backwards or forwards. The problem is finding a word with an accented character using the GREP mode.
    In using the Find/Replace dialog I cannot find André. Nor Andr\x{00E9}, using Unicode. So if the dialog won't work it appears a script won't work. If I use "Andre" in the Search field it will find "Andre" and "André."
    However I did find that if I change the GREP function in the script to the text mode I can find only words with accented characters and then replace them to my heart's content.
    Tom
    function theTextChanger(docRef,textFindIt,textChangeIt){
        app.findTextPreferences = NothingEnum.NOTHING;
        app.changeTextPreferences = NothingEnum.NOTHING;
        app.findTextPreferences.findWhat = textFindIt;
        app.changeTextPreferences.changeTo = textChangeIt;
        var arrTextFindIt = myDoc.changeText();
        return arrTextFindIt;
    }//end theTextChanger

  • How to search for a string in a DefaultListModel

    I have a list of names stored in a DefaultListModel and would like to know how i can search for a particular name
    i assume i would have to use the method below but not sure of how to implement it
    so basically i would have a texfield where a user can type in a name to find in the list
    public int indexOf(Object elem)
    Searches for the first occurence of the given argument.
    Parameters:
    elem - an object.
    or i might be wrong
    Any ideas of how to write this mechanism
    Can anyone please help on this

    The DefaultListModel uses a Collection of some sort (Vector at present) to store data. You can get this data in two ways:
       DefaultListModel model = (DefaultListModel)list.getModel();
        Enumeration e = model.elements();
        while(e.hasMoreElements()) {
          if (e.nextElement().equals(elem)) return;
        }or
        Object[] array = model.toArray();
        for (int i = 0; i < array.length; i++) {
          if (array.equals(elem)) return;

  • How to search for words in a string?

    I have a list of strings that I need to search for instances
    of a certain word (or part of that word) is there a way of doing
    this in flash please?

    Quickest and easiest way to do it is to search through an
    array of manually entered words.

  • Searching for an entry in a file that contains 2 words or more...

    Hey :)
    I created a Binary Search Tree that would hold a list of words located in a .txt file. So, basically, the objective of the program is to search through a typed up document for the words in the search tree, and if the word is found, return it to the user to see.
    I have that part working, but what I'm having trouble with is one of the entries in the file. The entry is "data structure." All the other entries are 1 word, like queue, depth-first, etc...but this one is 2 words. I'm having trouble making it so that the search will detect the 2-word entry, "data structure." How do I go about searching for entries that are 2 or more words in length?
    I have been struggling with this for some time, and I don't know if it's just me, but I'd really like to get this done since this is the only thing I'm having trouble with right now. I thought I could figure this out, but I'm just putting too much time into it, and I need to submit this tomorrow.
    Any help would really be appreciated! :)
    Take care,
    Alex

    Yea, I was thinking of doing that myself. Turning the two words into one word, so it'll end up like, "datastructure," but how do I do that? Would I use the substring method? Or is there something else that I can use to get rid of whitespace. I'll look that up now on google or something, but in the meantime, if anyone can help me out with this, it would be great.
    Just for a reminder, this is my problem :: I need to be able to locate an entry in my document that has 2 words in it. In this case, the entry is, "data structure." How can I go about searching for this 2 word entry? It seems to be a bit more complex than merely searching for one word. Any help you can provide me would be great! :)
    Here's the code for the Binary Search Tree:
    import java.io.*;
    import java.util.*;
    public class KeywordBinarySearchTree
         BinaryNode root;
         //static String[] docWords; // captures each of the words into an array while ignoring punctuation
         public KeywordBinarySearchTree()
              root = null;
         public void preOrderTraversal()
              preOrderTraversal(root);
         public void inOrderTraversal()
              inOrderTraversal(root);
         public Comparable findNode(Comparable node)
              return dataOfNode(findNode(node, root));
         public Comparable dataOfNode(BinaryNode node)
              if (node == null)
                   return null;
              else
                   return node.nodeData;
         public BinaryNode insertInOrder(Comparable iNodeData)
              BinaryNode nodeWalker;   // used to walk through each of the nodes until the appropriate spot
                                            // is found to insert the node of data
              BinaryNode parentNode = new BinaryNode(iNodeData); // represents the new root node after each pass through the tree
              if (root == null) // if it's a brand new tree with no nodes, then insert the new root of the tree
                   root = new BinaryNode(iNodeData);
              else
                   nodeWalker = root; // sets current root of tree to nodeWalker
                   while (nodeWalker != null) // will start its first iteration of the loop at the top of the tree
                        parentNode = nodeWalker;
                        if (iNodeData.compareTo(nodeWalker.nodeData) < 0) // if the data to be inserted is less than the current
                                                                                       // node in the tree
                             nodeWalker = nodeWalker.leftChild;                  // set nodeWalker to the left child of that node
                             System.out.println("INSERT NODE: LEFT CHILD");
                        else
                             nodeWalker = nodeWalker.rightChild;                 // otherwise, set nodeWalker to the right child of that node
                             System.out.println("INSERT NODE: RIGHT CHILD");
                   } // this loop will determine where the node has to travel to get to the appropriate destination. once the nodeWalker
                     // has reached its final stop, the while loop exits into the statements below to insert the new node of data
                   if (iNodeData.compareTo(parentNode.nodeData) < 0)
                        parentNode.leftChild = new BinaryNode(iNodeData);
                        System.out.println("INSERT NODE: PARENT NODE LEFT CHILD");
                   else
                        parentNode.rightChild = new BinaryNode(iNodeData);
                        System.out.println("INSERT NODE: PARENT NODE RIGHT CHILD");
              return parentNode;
         public BinaryNode findNode(Comparable searchNode, BinaryNode bn)
              if (bn == null)
                   return null;
              else
                   while (bn != null)
                        if (searchNode.compareTo(bn.nodeData) < 0)
                             bn = bn.leftChild;
                             //System.out.println("FIND NODE: LEFT CHILD DETECTED");
                        else if (searchNode.compareTo(bn.nodeData) > 0)
                             bn = bn.rightChild;
                             //System.out.println("FIND NODE: RIGHT CHILD DETECTED");
                        else // word has been spotted in the tree!
                             System.out.println(bn.nodeData);
                             return bn;
              return null;
         public void preOrderTraversal(BinaryNode bn)
              if (bn == null)
                   return;
              System.out.println(bn.nodeData);
              preOrderTraversal(bn.leftChild);
              preOrderTraversal(bn.rightChild);
         public void inOrderTraversal(BinaryNode bn)
              if (bn == null)
                   return;
              inOrderTraversal(bn.leftChild);
              System.out.println(bn.nodeData);
              inOrderTraversal(bn.rightChild);
    // and then the code after this is the public static void main code, which I posted snippets of above.

Maybe you are looking for

  • Facing problem in constructing a sql query

    I want a SQL Query through which I can Select all the values in a column of a table( which is Primary Key and another field in the table refers this field) I want to select all the values of the primary key which are either reffered by a particular v

  • Can I remove the logon/password prompt at startup?

    I am using Oracle Solaris 11 on one of my PC's in the house, there are no security requirements so is there a facility to turn off or deactivate the logon/password feature please? Thanks. Clive. Edited by: user13509226 on Jan 6, 2013 9:34 AM

  • Unity 7 Licensing Question

    Hi all, We recently upgraded Unity 4 to Unity 7 in a-la-carte licensing. As far as my understanding goes the user licensing model in Unity 7 is that all subscribers are UM subscribers and there are no more VM subscribers any longer. Below is a Unity

  • Color Problems in PSE11

    Hi. I've had Photoshop Elements 11 since December (because it was a free program after I bought a Wacom tablet) and there were no problems until now. I have a bit of experience with other adobe programs (on a mac, but alas, I use a PC) but I have rea

  • My photo stream will not sync with window 7 computer

    So frustrating!