Parsing some data

Hi,
I want to parse a string which can contain x number of up/down arrows.
These are represented by the unicode codes of \u2191and \u2193. Now i need to extract the positions of all of these items and replace the text with spaces where an arrow appears.
What is the best way to do this. Im thinking of using the stringtokenizer and getting setting the delim for the up and down arrows. However once I have these tokens I cant fiqure a way to replace the original text with spaces where these appear.
Any good suggestions?
Thanks

If you know the number of arrows, you can use an array.
If you don't know the number, you can either use an array with the same size as the char array (worst case), or use a Vector/ArrayList. Perhaps make a class that can hold the position and direction:
class Arrow {
  public static final char UP = '\u2191'; // dunno if this is up or down char
  public static final char DOWN = '\u2193';
  private final int pos;
  private final char direction;
  public Arrow(int pos, char direction) {
    this.pos = pos;
    this.direction = direction;
  public int getPos() { return pos; }
  public String getDirection() {
    if (direction == UP)
      return "UP";
    return "DOWN";
ArrayList pos = new ArrayList();
for (int x = 0; x < s.length(); x++) {
  if (s.charAt(x) == '\u2191' || s.charAt(x == '\u2193') {
    System.out.print(" ");
    pos.add(new Arrow(x, s.charAt(x));
  } else {
    System.out.print(s.charAt(x);
    // this is not an arrow.
for (int x = 0; x < pos.size(); x++) {
  Arrow arrow = (Arrow)pos.get(x);
  System.out.println("Arrow at pos: "+arrow.getPos()+" direction: "+arrow.getDirection());
}

Similar Messages

  • Parse table data from HTML page

    Hello. I have a program that creates an HTML page with several tables to present some data. What I would like to do is extract the data row by row from one of the tables, and parse the data I'm interested in from each row. Can anyone suggest how I should approach this problem?

    Andrew,<br /><br />1. If you want to append these data to the existent one, you've to read the XMP of the file.<br /><br />2. You've to add or modify the Dublin Core Description field <dc:description><br /><br />For example:<br /><rdf:Description rdf:about='uuid:d659be9a-21d7-11d9-9b6a-c1fd593acb83'<br />  xmlns:dc='http://purl.org/dc/elements/1.1/'><br /> <dc:format>image/jpeg</dc:format><br /> <dc:description><br />  <rdf:Alt><br />   <rdf:li xml:lang='x-default'>Image Caption</rdf:li><br />  </rdf:Alt><br /> </dc:description><br /></rdf:Description><br /><br />3. You've to replace the app1 block on the JPG with the new XMP<br /><br />Regards,<br /><br />Juan Pablo

  • Parse Serial Data

    I am communicating with an instrument that takes a query and puts out a status packet. I have to parse the data and get information about the instrument status. The status packet is a multi byte data with MSB first and all bytes are 8 bit.
    I get a string output with that says something like this..."CC\B0\CC\B0\CC\D0\CC\D0\CC\B0\CC\D0\00\...". I have not posted the entire string. But I need to parse thsi string and get meaningful values out of it.
    I read some of the previous posts which suggest using the Type Cast function. But I am not sure how it works and how to use it. Also tried using the String to Byte Array function but do not know how to use the array to obatin values that correspond to a voltage.
    Thanks.

    LabVIEW uses Big Endian format for its binary numbers, while most Windows programs use Little Endian format. LabVIEW uses Big Endian, because that is what the MacOS uses, and LabVIEW was created first for the Macintosh. So must test and see what is correct.  In my example I have assumed that the datatype is I16, but it could also be U16
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)
    Attachments:
    demo.vi ‏9 KB

  • Some data in ... could not be read or written. (Error code -36).

    Hello.
    I just got a Lacie 512mb disk, and thought it would be ideal for running my iTunes library off of. Got the disk, ran it through its paces, hooked it up to my Mac mini, and I can't seem to copy hardly any files over. Here's one error (but you can replace "iTunes Library" with any song and it's the same thing)...
    'The Finder cannot complete the operation because some data in "iTunes Library" could not be read or written. (Error code -36).'
    So, I think there's disk or file damage, etc. I boot off an external and run Disk Utility, DiskWarrior and TechToolPro against it - everything checks out fine.
    But I can't copy files from the mini's internal to my external Repair Boot disk or the Lacie 512. Always that same -36.
    So, at first I think it's the mini, then I think it's the Lacie, because it's new, so I reformat it: same issue. And that coupled with it won't copy to my Repair Boot, makes me think the mini again.
    But, I've got a g1 iPod mini hooked up (formatted in hfsj+), and I can copy this file to the iPod mini, but no where else. I not sure what this makes me think.
    And, I can duplicate the file on the Mac mini. In fact, if it's a song file that won't copy (none of them will), I can play it just fine.
    Thanks.
    Mac mini   Mac OS X (10.4.3)  

    I experienced a problem in a familiar way.
    After a recording session I tried to copy the complete folder with session and sound files to another disk (original and target disk both LaCie d2 250 FW800).
    Somehow the proces stopped prompting an -36 error over some files.
    When I look up these files in the Finder, it seems to have an iTunes audio-file icon instead of a ProTools audio-file icon (and so other standard app to open with). All the other files will copy fine. The files will play with quicktime in the preview window.
    Any-one a solution?
    Almost seems like some kind of copy protection, like implied earlier in this thread. I hope it's not. These are the originals...

  • "the finder cannot complete the operation because some data in [name of iMovie file] could not be read or written (Error Code 26)

    Hi all,
    I have an iMovie project in iMovie HD 6.0.3. (Mac OS 10.5.8)
    It plays, but I cannot copy the file (including saving it to a flash drive). I get either a message
    "the finder cannot complete the operation because some data in [name of
    iMovie file] could not be read or written (Error Code 26)" or the
    message "A project file is missing. The file [name of the QuickTime
    movie inside the project.dv] couldn't be opened and is being skipped."
    This happened suddenly, I was able to save a backup version numerous
    times while working on the project.
    I followed some of Karl Petersen's advise on apple discussions. I opened
    the package contents, and everything seems to be there. The source file
    (original QuickTime movie) is there and can be opened and played. I
    replaced the current project file with the backup in the package
    contents, but that did not change anything. I was able to export the
    movie timeline into a new project as a single clip, but would like to be
    able to copy the current project.
    Thanks for any ideas..

    Make sure all drives are formatted as "Mac OS Extended". (Journalling preferred, but not necessary).

  • Unable to  set some dates  in Adobe bridge cs2

    HI ALL
    Our keywording team using  the  Adobe bridge CS2.
    Kindly  hep me to understand Why  some dates  Like
    1/1/1970
    1/1/1642
    1/1/1890
    etc  .....
    I unable to  set in  ITPC image Tab  information .............
    Lakhan

    Hi
    Thanks for revert ......
    I  tried   with  CS2 & CS3  but only  specific  dates like (1/1/1970) i above  mentioned  is still  not   reflecting in IPTC image  info   ........
    Please suggest....

  • Sharepoint list dataheet view error "Cannot connect to the server at this time. You can continue working with this list, but some data may not be available"

    I have a List which is having around 14000 items in it.while opening that list in datasheet view it is giving error .
    Below is a summary of the issue:
    After selecting datasheet view beow error occurs:
        "Cannot connect to the server at this time.  You can continue working with this list, but some data may not be available."
        "Unable to retrieve all data."
        The item counts displays say 100 out of 14000 items.
    Exporting List to excel is giving only 2000 records out of 14000 records.
    Other Observations   -  
    This is happening to only one list on the site .There are other lists in the site whose no. of records is equal to 8000 to 9000.They are working absolutely fine without any error.
    Also, If I am saving this list as a template and creating another list with it ,then it is working absolutely fine with 14000 records,so the issue does not seem to be related with no. of records as the template list is working fine.
    I have checked the Alternate access mapping setting ,its fine.
    It should not be related to lookup,datefield or any other column as the list created from it template is working fine with all these columns.
    I checked below links also ,but doesn't seem to work in my case.
    http://social.technet.microsoft.com/forums/en-US/sharepointadminprevious/thread/974b9168-f548-409b-a7f9-a79b9fdd4c50/
    http://social.technet.microsoft.com/Forums/en-US/smallbusinessserver/thread/87077dd8-a329-48e8-b42d-d0a8bf87b082
    http://social.msdn.microsoft.com/Forums/en-US/sharepointgeneral/thread/dc757598-f670-4229-9f8a-07656346b9b0

    I have spent two days to resolve this issue. Microsoft has released two KBs with reference to this issue...but are not appearing in search results at the top.
    I am sharing my finding.
    1. First install the
    KB2552989 (Hopefully you might have already installed it. The KB detetcts it and informs the user.)
    2. Then update registry by adding new key for data fetch timeout as mentioned inKB2553007
    These two steps resolved the issue in our environment. Hope it might help others as well.
    Pradip T. ------------- MCTS(SharePoint 2010/Web)|MCPD(Web Development) https://www.mcpvirtualbusinesscard.com/VBCServer/paddytakate/profile

  • Cannot move any files into trash to delete them. I get a Trash warning box saying "The Finder cannot complete the operation because some data in 'file name' could not be read or written.(Error code - 36)".Macbook has so much data it is almost not working

    Cannot move any files into trash to delete them. I get a Trash warning box saying "The Finder cannot complete the operation because some data in 'file name' could not be read or written.(Error code - 36)".Macbook has so much data it is almost not working.
    I have tried reseting to factory settings by removing battery and holding down the power switch for more than 5 sec but this does nothing.
    Any ideas would be greatly appreciated as I think with so much unwanted data on the desktop and other places the whole os will crash very soon.
    Thanks, Rick

    The hard drive may be dying anyway, or the directory damaged because it is so full.  You should never let the hard drive get over 85% full.
    A -36 error is a read/write error.
    All you did with the power is reset the SMC.  Does nothing to reset everything to factory settings. 
    Do you have your original 10.4 installer discs for the MacBook?
    Is your data backed up?

  • Problems Receiving Emails and some data on WIFI since latest software update.

    Problems Receiving Emails and some data on WIFI since latest software update. 
    My blackberry torch will not receive emails on wifi since the latest software update, I've tried numerous wifi networks and several handsets, even had them replaced and received a brand new. Still the same problem. 
    When turning off the wifi network on the torch, the phone will stall for 5-10min while it tries to communicate with the network (vodafone) to receive outstanding emails and data. 
    Can someone please inform Blackberry and get a quick fix on this

    Sounds like you have Do NOt Disturb turned on.
    settings - do not disturb - off

  • LOG_FILE_NOT_FOUND when running cleaner manually after some data purge

    I hit LOG_FILE_NOT_FOUND error when running cleaner manually after some data purge, I searched the forum, found someone also faced the same issue before, but cannot find any clue on how to fix it. Below is the error trace and followed by our configurations
    Caused by: com.sleepycat.je.EnvironmentFailureException: (JE 4.1.6)
    Environment must be closed, caused by:
    com.sleepycat.je.EnvironmentFailureException: Environment invalid because of
    previous exception: (JE 4.1.6) /scratch/tie/thirdeye/index/data-store
    fetchTarget of 0x50f/0x3fb9dd6 parent IN=368491717 IN
    class=com.sleepycat.je.tree.IN lastFullVersion=0x510/0x2ca7d18
    parent.getDirty()=false state=0 LOG_FILE_NOT_FOUND: Log file missing, log is
    likely invalid. Environment is invalid and must be closed.
    at
    com.sleepycat.je.EnvironmentFailureException.wrapSelf(EnvironmentFailureExcept
    ion.java:196)
    at
    com.sleepycat.je.dbi.EnvironmentImpl.checkIfInvalid(EnvironmentImpl.java:1439)
    at com.sleepycat.je.Environment.checkEnv(Environment.java:2117)
    at com.sleepycat.je.Environment.checkpoint(Environment.java:1440)
    at
    com.oracle.thirdeye.datastore.DataStoreManager.clean(DataStoreManager.java:402
    at
    com.oracle.thirdeye.infostore.InfoStoreManager.clean(InfoStoreManager.java:301
    ... 11 more
    Caused by: com.sleepycat.je.EnvironmentFailureException: Environment invalid
    because of previous exception: (JE 4.1.10)
    /scratch/tie/thirdeye/index/data-store fetchTarget of 0x50f/0x3fb9dd6 parent
    IN=368491717 IN class=com.sleepycat.je.tree.IN
    lastFullVersion=0x510/0x2ca7d18 parent.getDirty()=false state=0
    LOG_FILE_NOT_FOUND: Log file missing, log is likely invalid. Environment is
    invalid and must be closed.
    at com.sleepycat.je.tree.IN.fetchTarget(IN.java:1332)
    at com.sleepycat.je.tree.IN.findParent(IN.java:2886)
    at com.sleepycat.je.tree.Tree.getParentINForChildIN(Tree.java:881)
    at com.sleepycat.je.tree.Tree.getParentINForChildIN(Tree.java:809)
    at
    com.sleepycat.je.cleaner.FileProcessor.findINInTree(FileProcessor.java:1152)
    at com.sleepycat.je.cleaner.FileProcessor.processIN(FileProcessor.java:1090)
    at
    com.sleepycat.je.cleaner.FileProcessor.processFile(FileProcessor.java:538)
    at com.sleepycat.je.cleaner.FileProcessor.doClean(FileProcessor.java:241)
    at com.sleepycat.je.cleaner.Cleaner.doClean(Cleaner.java:463)
    ------------Configurations-------------------------
    EnvironmentConfig.ENV_RUN_CLEANER -> false
    EnvironmentConfig.CHECKPOINTER_HIGH_PRIORITY -> true
    EnvironmentConfig.CLEANER_EXPUNGE -> false
    Any hints are appreciated. I'm also working for Oracle CDC, feel free to call me at 861065151679 or drop me an email at [email protected] so that we can talk more in detail
    Anfernee

    Anfernee, I will contact you via email.
    --mark                                                                                                                                                                                                                   

  • For the last month or so my icloud won't back up, it keeps telling me that there is too much storage and I need to delete some data. But I have deleted between 3-400 photos and it is still saying the same, can anyone please help

    For the last month or so my icloud won't back up, it keeps telling me that there is too much storage and I need to delete some data. But I have deleted between 3-400 photos and it is still saying the same, can anyone please help

    If they were deleted from your camera roll that should have resulted in a corresponding decrease in the estimated size of your next backup.
    If it's still saying that you don't have enough storage to back up, read through this article: http://support.apple.com/kb/ht4847.  It provides some suggestions for reducing your iCloud storage, such as deleting unneeded email. 
    The other area to look at is your text messages.  These are included in the backup.  If you have lots of photos and videos attached to your messages, that can significantly increase the size of your backup.  If that's the case, deleting these may make a big difference.

  • I have photos on a cd which I'm trying to open .  If I click on them I can see the picture in the preview, but when I double click it doesn't recognise the picture.  They are all in .jpg format.  Tried copying them but it said some data cannot be read.

    I have photos on a cd which I'm trying to open .  If I click on them I can see the picture in the preview, but when I double click it doesn't recognise the picture.  They are all in .jpg format.  Tried copying them but it said some data cannot be read.  The files exist but I just can't seem to view them

    Select one and hit the Space bar to view it in QuickLook. Use the forward arrow keys to move from file to file.   If the file can't be viewed in the QuickLook mode then the file is damaged and probably can't be copied or moved.
    You could try a photo file recovery application like  MediaRECOVER which can scan the memory card and tell you what files, if any, can be recovered before you have to purchase it.
    OT

  • How to delete some date in target table at a mapping?

    How to delete some date in target table at a mapping?
    I extract date from source tabel into target table,
    but before extract date I want to delete some date from target?
    how to do?

    Just to change a bit of terminology in the reply, within the mapping, click on operator properties and choose TRUNCATE/INSERT.
    Note that truncate is dependent on constraints, so you probably must disable those before doing this. You can of course do DELETE/INSERT...
    Jean-Pierre

  • Import some data from one oracle to another...

    Hi Guys,
    we have 2 oracle database servers on 2 different machines with schema.
    I want to import some data from a specific table from one oracle into another oracle.
    what is the way to do that.
    Please help in details
    Imran Baig

    Hi,
    Thanks for the reply.
    Tables are already created in both of the oralce databases only the data varies. I just have to import only few records from one oracle to another with the same user name and table already existing.
    I have tried using database link. I can view records from the other oracle database but as soon as i write an insert command oracle gets held. I cant do anything.
    Is there any other way?
    Imran

  • Script for parsing xml data and inserting in DB

    Thank you for reading.
    I have the following example XML in an XML file. I need to write a script that can insert this data into an Oracle table. The table does not have primary keys. The data just needs to be inserted.
    I do not have xsd file in this scenario. Please suggest how to modify Method 1 https://community.oracle.com/thread/1115266?tstart=0 mentioned so that I can call the XML mentioned below and insert into a table
    Method 1
    Create or replace procedure parse_xml is 
      l_bfile   BFILE; 
      l_clob    CLOB; 
      l_parser  dbms_xmlparser.Parser; 
      l_doc     dbms_xmldom.DOMDocument; 
      l_nl      dbms_xmldom.DOMNodeList; 
      l_n       dbms_xmldom.DOMNode; 
      l_file      dbms_xmldom.DOMNodeList; 
      l_filen       dbms_xmldom.DOMNode; 
      lv_value VARCHAR2(1000); 
       l_ch      dbms_xmldom.DOMNode; 
    l_partname varchar2(100); 
    l_filename varchar2(1000); 
      l_temp    VARCHAR2(1000); 
      TYPE tab_type IS TABLE OF tab_software_parts%ROWTYPE; 
      t_tab  tab_type := tab_type(); 
    BEGIN 
      l_bfile := BFileName('DIR1', 'SoftwareParts.xml'); 
      dbms_lob.createtemporary(l_clob, cache=>FALSE); 
      dbms_lob.open(l_bfile, dbms_lob.lob_readonly); 
      dbms_lob.loadFromFile(dest_lob => l_clob,    src_lob  => l_bfile,    amount   => dbms_lob.getLength(l_bfile)); 
      dbms_lob.close(l_bfile);  
      dbms_session.set_nls('NLS_DATE_FORMAT','''DD-MON-YYYY'''); 
      l_parser := dbms_xmlparser.newParser; 
      dbms_xmlparser.parseClob(l_parser, l_clob); 
      l_doc := dbms_xmlparser.getDocument(l_parser); 
        dbms_lob.freetemporary(l_clob); 
      dbms_xmlparser.freeParser(l_parser); 
      l_nl := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'/PartDetails/Part'); 
        FOR cur_emp IN 0 .. dbms_xmldom.getLength(l_nl) - 1 LOOP 
        l_n := dbms_xmldom.item(l_nl, cur_emp); 
        t_tab.extend; 
        dbms_xslprocessor.valueOf(l_n,'Name/text()',l_partname); 
        t_tab(t_tab.last).partname := l_partname; 
        l_file := dbms_xslprocessor.selectNodes(l_n,'Files/FileName'); 
        FOR cur_ch IN 0 .. dbms_xmldom.getLength(l_file) - 1 LOOP 
          l_ch := dbms_xmldom.item(l_file, cur_ch); 
          lv_value := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_ch)); 
          if t_tab(t_tab.last).partname is null then t_tab(t_tab.last).partname := l_partname; end if; 
          t_tab(t_tab.last).filename := lv_value; 
        t_tab.extend; 
       END LOOP; 
       END LOOP; 
        t_tab.delete(t_tab.last); 
      FOR cur_emp IN t_tab.first .. t_tab.last LOOP 
      if t_tab(cur_emp).partname is not null and  t_tab(cur_emp).filename is not null then 
        INSERT INTO tab_software_parts 
        VALUES 
        (t_tab(cur_emp).partname, t_tab(cur_emp).filename); 
        end if; 
      END LOOP; 
      COMMIT; 
      dbms_xmldom.freeDocument(l_doc); 
    EXCEPTION 
      WHEN OTHERS THEN 
        dbms_lob.freetemporary(l_clob); 
        dbms_xmlparser.freeParser(l_parser); 
        dbms_xmldom.freeDocument(l_doc); 
    END; 
    <TWObject className="TWObject">
      <array size="240">
        <item>
          <variable type="QuestionDetail">
            <questionId type="String"><![CDATA[30]]></questionId>
            <questionType type="questionType"><![CDATA[COUNTRY]]></questionType>
            <country type="String"><![CDATA[GB]]></country>
            <questionText type="String"><![CDATA[Please indicate]]></questionText>
            <optionType type="String"><![CDATA[RadioButton]]></optionType>
            <answerOptions type="String[]">
              <item><![CDATA[Yes]]></item>
              <item><![CDATA[No]]></item>
            </answerOptions>
            <ruleId type="String"><![CDATA[CRP_GB001]]></ruleId>
            <parentQuestionId type="String"></parentQuestionId>
            <parentQuestionResp type="String"></parentQuestionResp>
          </variable>
        </item>
        <item>
          <variable type="QuestionDetail">
            <questionId type="String"><![CDATA[40]]></questionId>
            <questionType type="questionType"><![CDATA[COUNTRY]]></questionType>
            <country type="String"><![CDATA[DE]]></country>
            <questionText type="String"><![CDATA[Please indicate]]></questionText>
            <optionType type="String"><![CDATA[RadioButton]]></optionType>
            <answerOptions type="String[]">
              <item><![CDATA[Yes]]></item>
              <item><![CDATA[No]]></item>
            </answerOptions>
            <ruleId type="String"><![CDATA[CRP_Q0001]]></ruleId>
            <parentQuestionId type="String"></parentQuestionId>
            <parentQuestionResp type="String"></parentQuestionResp>
          </variable>
        </item>
      </array>
    </TWObject>

    Reposted as
    Script to parse XML data into Oracle DB

Maybe you are looking for