IS it right using StringTokenizer in this case ...(pls see code& expl)

Hi
This project takes a comma delimited input file , where the values are in double quotes .The inputfile has more than 200 columns.
ex: "12345","1","USA County School,Public","Rank1","TX","USA"
if we observe the 3 rd column in the first record in the above example , has value as "USA County School,Public'
Now i have to get each value of the record , add some conditions and create few output files for further use .
The first step in my code is :-
1 ) using StringTokenizer and creating tokens
When i am creating tokens , token3 ie., column3 value is splitting into 2 tokens . where as actually it should be only one token as column3 value is in double quotes.
how can i solve this problem of not creating 2 tokens , when a value is in quotes and it uses a comma .
pls help me .. what is the other way to generate the values which are in double quotes neglecting the comma (if any exists within the quotes) for further use from each record of the input record .
Thanks

1sai wrote:
i am new to java , can u tell me which csv parser i should use to acheive my objective.Any one.
>
and a skeleton of code will be very helpful.The parser probably comes with some example code. Examine the site.

Similar Messages

  • How to use two split this method in my code

    How to use two split this method in my code
    if i got one string line which like this
    ("aa!bb!cc~ab!bc!cd") a
    nd want to use two split to spare ! and ~ this seal for my spare point how that output
    has come diff ?
    public static void main(String[] args) {
        String str = "aa!bb!cc~ab!bc!cd";
        String strs[]= str.split("~");
        String strE[]= str.split("!");
        int count =0;
        for(int j=0; j < strs.length; j++){
          for (int i = 0; i < strE.length; i++){   
              System.out.println(count + " " + strE);
    count++;
    the output how can it be like this
    0 aa
    0 bb
    0 cc
    1 ab
    1 bc
    1 cd

    Move your second slit inside the first loop, so you are splitting the substring, not the entire string.

  • Will it feasable to use Module in this case :screen shot attached

    Hi ,
    We are developing a Application which provides several facilities like Forum , Remote User , --- etc screen shot attached for this reference .
    Please tell me will it feasable to develop each of this service as a Module ??
    Please tell me shall we go for seperate Modules or for Seperate Components , what will be feasable
    Please share your experience

    Anybody please tell me if its better to go using Modules Approach , in case if they were part of the Application itself .
    Thanks.

  • Preventing SQL injection - can't use cfqueryparam in this case

    Hello. I have a form with a checkbox next to each row.  If the user checks some boxes, then clicks the "Delete" button, I want to execute the following query, but I want to protect it from sql injection attacks:
        <cfquery datasource="#application.mainDS#">
            delete userMessages
            where messageID in (#form.messageID#)
        </cfquery>
    As written above, it works fine.  But if I try to protect this code with <cfqueryparam value="#form.messageID#" cfsqltype="cf_sql_varchar">, I get this error: "Conversion failed when converting the varchar value '7,21' to data type int" (7 and 21 are the messageID's to be deleted).  Obviously the comma prevents conversion to an integer.
    If I use cfsqltype="cf_sql_integer", then the string gets converted to a single integer (in this case 40015, which is nonsense).
    I tried passing form.messageID to a stored procedure, but I seemed to have the same problem there.  I could run the query in a loop where I just delete one row at a time, but I'd like to run just one query if I can do it safely.  Any ideas?
    Thanks.
    PK

    I agree that you should not do an SQL "DELETE" from a web page.  Instead, use "soft deletes," where you contrive for there to be a deleted_flag (boolean), and maybe deleted_by (varchar) and deleted_timestamp.  Then create an SQL "VIEW" which automagically omits the "deleted" records.
    It is also a very good idea to refer to the records using a nonsensical, made-up "moniker" instead of actual record-IDs.  You see, "if I am a nasty person and I know that there is a record #123456, then I'll bet I know the record-IDs of 123,455 other records, too."  But if you refer to the record as "QZB0E9S" and the next record-id in the list is "4Q_9RJPEM2" then it won't take me long to realize that I can't get too far, not even by brute-force.  (And if I see that the record-IDs seem to have verification tags, like "QZB0E9S:4E396", then I know that I am really scroo'd in my hacking-attempt because even if I did somehow million-monkeys my way into a valid record-ID, I've got no earthly idea how to come up with the tag.
    It pays to code defensively, like this.  And it doesn't really take more time.  Without question, always use <cfqueryparam> !!

  • 10 GBs of "other" space used, other (in this case) isn't anything

    i already had to send back on 3G, and since i got the replacement i've had to restore it twice, and it has yet to make a new backup for me, it starts but never finnishes.
    the issue, when i sync(ed) the last time after restoring, it started sizing the pictures and i could see the meter in yellow going up. in the moring i look and i have about a gig audio used, little over a gig video, little over a gig photos, and 10 GB other..... now i saw the other before it moved on from apps and it was almost nothing. and one of the pop up windows said it couldn't move any more photo albums cause there wasn't enough space. i've looked through all the tabs in itunes sync section and there is nothing that could be representing the "other"... and apps are far to small even if i had 100.
    i've tried unchecking more videos and other things and it does take that space back but itunes hasn't noticed its mistake yet.
    any advice?
    there is 1.03GB free space right now (my photo albums are probably bigger then that)

    thank you i expected someone to say that..... i didn't have this problem before, and so the corrupt file would have to be an application? cause there aren't any other files in the other cadagory that i have checked. could it have become corrupt on the transfer to the phone... otherwise i'll have the same problem again. it seems that none of the apps should be corrupt from the download from itunes, should i just assume this was a random thing, cause those keep happening to me, my phone)

  • How to use LIKE in this CASE?

    There are multiple values that start with "Aerospace".  All of them are going to be set to the same value.  I'm trying to write a Case Statement that will replace all of them with the new value, but i can't get the LIKE to work correctly.
      This can probably be done with REPLACE, but It's bugging me that I can't get the LIKE to work.  
    I've tried a few variations, but compiler hasn't like any of them.  I'm hoping to have one line of code that will work for all of the possible choices.
    What is the best way to use a LIKE or similar thing (such as CONTAINS) to set all of the fields with "Aerospace" at the beginning?
    Sorry for the small font above.  I didn't see how to change it.
    'New Sector Focus' = CASE sectorfocus
    WHEN sectorfocus LIKE 'Aerospace%' THEN '201010 - Aerospace & Defense'
    ELSE sectorfocus
    END

    CASE expression looks good. CASE blog: 
    http://www.sqlusa.com/bestpractices/training/scripts/casefunction/
    >Sorry for the small font above.  I didn't see how to change it.
    Use the HTML icon to edit the html code.
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • How to use recursive in this case?

    I have a tree showed in bweb rowser UI like this
    +- node1          
    | |
    | +- node_value1a    X 
    | +- node_value1b     
    | +- node_value1c      X
    |
    +- node2    X      
    | |
    | +- node2a      X
    | | |
    | | +- node_value2a1   X
    | | +- node_value2a2   X
    | |
    | +- node_value2b     X  
    |
    +- node3          
    |
    +- node_value3a    X 
    +- node_value3b     
    At the begining I will retrieve the user permission for each node value and show them as checked "X" , Each node have a biding userObject with property key and check status and other more(we will focus on node key name and check status only). The parent node will be calculated as checked only if all its children are checked. So every time user click one node or node value(node without children). I will re-calculate the all tree nodes status based on all node_value again and update all check box in UI page. This seems need to go from bottum up since I will do:
    . Upon the clicking of one node(can be any node) I will send a http request back to server with that node key name. I will then do the following:
    if it is uncheck requrest -> updated all its childrens as unchecked -> recalculate all its parent to update their check status to unchecked
    if it is check requrest -> updated all its children as checked -> recalculate all its parent to update their check status.(may be check or uncheck depend on other sibling node status).
    The porpuse is to update that user's access right.
    I get lost when I try coding this feature. Could sonebody here help me out ? Thanks

    So how far have you got so far?

  • New to Using Time Machine, Should I Even Use It in This Case?

    Hey everyone
    So I just started a full Time Machine backup on my Macbook Pro to my Seagate 2TB External Hard drive. I make music, so I have a lot of projects and sounds, which I would like to have backed up just incase something happens to my Macbook. I have around 250GB of stuff on my computer, and it says that's it's going to take around 12 hours to back everything up. I'm new to using Time Machine, so I have a few questions:
    Will this occur all the time if Time Machine is running? Like, will it keep updating the data I already have and replacing it, or will it just backup new changes/files after this first backup is complete? Is there an option/preference I can change so it only backs up new changes/files instead fully backing up every day?
    Does Time Machine store the files/folders onto the external hard drive, or is it just like a backup file that you run which backs up everything?
    Thank you guys in advance, really need help with this!

    You should not use a Time Machine backup drive for permanent data storage. Use a separate drive for that purpose. It's much safer. Time Machine will over time delete files if they are deleted from the source drive which makes Time Machine a poor long term storage option. If you want a permanent storage option buy a separate drive for that purpose, but do not use Time Machine. User other backup software:
    Suggested Backup Software
      1. Carbon Copy Cloner
      2. Get Backup
      3. Deja Vu
      4. SuperDuper!
      5. Synk Pro
      6. Tri-Backup
    Others may be found at VersionTracker or MacUpdate.
    Visit The XLab FAQs and read the FAQ on backup and restore.  Also read How to Back Up and Restore Your Files.

  • How to use counter in this case

    in my selection screen i have billing doc no-vbeln.
    in my ztable i have etimes a field.
    when i enter a bill doc no and press f8, my etimes feild in ztable sets to 1.
    my requirement is if i enter a bill doc as 97600654 for first time, etimes is 1.
    for second time if i enter that same bill doc i.e 97600654 , etimes should be 2 and if third then 3 and so on.
    if a new doc is entered then etimes is again 1.
    how to code this..plz provide some code.

    Hi Rudra,
    First You need to create a Ztable(say ZTT_VBELN_COUNT) with Three fields MANDT VBELN ETIMES.
    Now in your program add code as below;
    DATA wa_vbeln_count type line of ZTT_VBELN_COUNT.
    SELECT SINGLE * FROM ZTT_VBELN_COUNT INTO CORESSPONDING FIELDS OF wa_vbeln_count where VBELN = lv_vbeln.
    IF SY-SUBRC EQ 0.
       wa_vbeln_count-etimes = wa_vbeln_count-etimes + 1.
    ELSE
       wa_vbeln_count-vbeln = lv_vbeln.
       wa_vbeln_count-etimes = 1.
    ENDIF.
    MODIFY ZTT_VBELN_COUNT FROM wa_vbeln_count.
    Regards
    Karthik D

  • How to use to_date for this case?

    Hi,
    I bind parameters in java code.
    The param type in java is Timestamp and the data type in table is date.
    Here is the sql section printted in log:
    2004-08-01 10:00:00.0 <= table.datetime
    Why there is a ".0" after second?
    And how to use to_date to convert "2004-08-01 10:00:00.0"?
    Thanks!

    Hi,
    Here are a few possibilities
    SQL> select cast(timestamp '2004-08-01 10:00:00.0' as date) from dual;
    CAST(TIMESTAMP'2004
    2004-08-01 10:00:00
    SQL> select to_date('2004-08-01 10:00:00.0','YYYY-MM-DD HH24:MI:SS".0"') from dual;
    TO_DATE('2004-08-01
    2004-08-01 10:00:00
    SQL> select to_date(substr('2004-08-01 10:00:00.0',1,19), 'YYYY-MM-DD HH24:MI:SS') from dual;
    TO_DATE(SUBSTR('200
    2004-08-01 10:00:00

  • How can i use param in my select query ( see code)

    Hi ,
    I need to use the param instead of hardcoding the value in the select query , when i did that it is working .
    I think the limit of args is only till the end of main and my select query is in a method called Load() .
    How can i use the param in my select query .
    public static void main(String[] args){
    name = args[0];
    class= args[1];
    new Load();
    }//end of main
    public Load()
              try {
                   Class.forName(JDBC_DRIVER);
                   connection = DriverManager.getConnection(DATABASE_URL,"username","pw");
                   statement = connection.createStatement();
                   //First Query : pin and ticket number
                   ResultSet resultSet = statement.executeQuery("SELECT pin , ticketnumber from airport ,year where "+                                                                      "year.year_name= Here i need to use the param (instead of hardcoding) and year.class_year= Here too i need to use param");
    }// end of method Load()Edited by: 1sai on Sep 24, 2008 7:34 AM
    Edited by: 1sai on Sep 24, 2008 7:35 AM

    Might I suggest you change the structure of your program to the following:
    public class Load {
      private Connection conn;
      private PreparedStatement statement;
      public Load(String sql) {
        init(sql);
      protected void init(String sql) throws Exception {
        Class.forName(JDBC_DRIVER);
        conn = DriverManager.getConnection(DATABASE_URL, "username", "pw");
        statement = conn.prepareStatement(sql);
      public ResultSet execute(String p1, String p2) throws Exception {
        statement.setString(1, p1);
        statement.setString(2, p2);
        return statement.executeQuery();
      public void close() throws Exception {
        if (statement != null)
          statement.close();
        statement = null;
        if (conn != null)
          conn.close();
        conn = null;
      public static void main(String[] args) throws Exception {
        String sql = args[0];
        String param1 = args[1];
        String param2 = args[2];
        Load load = new Load(sql);
        ResultSet rs = load.execute(param1, param2);
        while (rs.next())
          System.out.println(rs.get(0));
        rs.close();
        load.close();
    }This allows you to use the same "Load" object for multiple queries with different parameters.
    I do not recommend you actually use the code above in any sort of production application. You should really take a look at Spring Framework along with an ORM tool like Hibernate or Ibatis to simplify your DAO layer.
    Hope this helps,
    David

  • Avoid Evaluate in this case?

    I am invoking a webservice that returns Java entry arrays for
    ldap user information.
    To display the name from each entry i have this code:
    <cfloop index="intIndex" from="0"
    to="#arraylen(topOfOrg.getEntryArray().getEntry())-1#">
    <cfoutput>#directReports.getEntryArray().getEntry(evaluate(intIndex)).getName()#</cfoutpu t>
    </cfloop>
    Should i avoid using evaluate in this case? And how could I
    if it is an option?
    Thanks for any thoughts/ideas.

    Thanks all for the feedback/discussion.
    I'm not an expert yet... just graduated with a bachelors in
    business adminstation with a CIS focus in december. That means i
    had about 3 programming classes and one web design class that had
    about 4 weeks on coldfusion. But ever since i was exposed to
    coldfusion i have enjoyed it. Landed a job after graduation as a
    web master of a site with coldfusion 5.0 applications.
    I recommened a new server and upgrade to coldfusion mx 7. And
    started redesigning our site and applications. Its been fun and
    challenging.
    This week i had the idea to make a dynamic org chart. Our
    corporation has a active directoy lookup web service, so I set out
    to consume it in coldfusion. Took some trial and error but i got
    consumption to work....
    I don't know java well, but the web service documentation
    said returns java entry array objects. Took some trial and error
    again to get the data out of the objects once they were returned.
    But got that working, then i expanded my querie to return multiple
    arrays within the object so i had to loop over it (i assume this is
    a resonably efficient way to get at each array).
    My original logical line of code was to use:
    <cfloop index="intIndex" from="0"
    to="#arraylen(directReports.getEntryArray().getEntry())-1#">
    <cfoutput>#directReports.getEntryArray().getEntry(intIndex).getName()#</cfoutput>
    </cfloop>
    This code returns this error: "The selected method getEntry
    was not found."
    coldfusion.runtime.java.MethodSelectionException: The
    selected method getEntry was not found.
    In response to that i set evaluate around the intIndex and it
    worked, but i had read evaulate was a costly operation, so i asked
    for help here. And got the excellent javacast alternative.
    The webservice return variable is directreports, a java
    object i believe, and it has a method to get to the result set of
    EntryArray and then each array in the result set has methods to
    reveal my data. Like name, work phone, job title, etc.
    Its a simple application, but everyone loves it so far.
    Thanks all!

  • Synchronization: useful or not in this case

    ok, I'm getting a bit confused if the synchronization is useful or not in this case.
    As far as i know, is synchronizsation required if more than one thread is able to enter a specified function/codefragment, but how about "atomaric" functions?
    long[]longarray = new long[10];
    String[]stringarray = new String[10];
    /*some code*/
    public String ThisCanBeEnteredByManyThreads(int index,int type){
    switch(type)
    case 1:
    return stringarray[10];
    case 2:
    return String.valueof(longarray[index]);
    }When I get it right, the return value will be a reference on the current String object. If another function now perform something like
    stringarray[index]="woods";
    longarray[index]=10; then it souldn't affect my reference I returned in the previouse function. Or is this not atomaric (only setting the reference, not the string creating)?
    Or is the function "String foo = stringarray[index]" not atomar?

    Don't get too hung up with the contract. If you do your calcs, you will discover that the contractvjust means you pay for the phone by installments over the duration of the contract. Often you end up paying less if you opt for sim only and buy your own phone. This way you can also buy any phone you want and best offf all, it will probably be unbranded. 
    Find yourself a nice N8, new or secondhand. I have one but it is not for sale.

  • TS1436 when i try to burn a playlist to a blank cd it asks me all the right questions says it is initialising the burn then ejects the blank cd it never used to do this but always does it now so i am unable to burn cds

    When i try to burn a playlist to a blank cd it asks me all the right questions and appears to be doing it then the message 'initializing burn' comes up and the cd is ejected it never used to do this but always does it now so i am unable to burn cds. Can anyone help?

    When i try to burn a playlist to a blank cd it asks me all the right questions and appears to be doing it then the message 'initializing burn' comes up and the cd is ejected it never used to do this but always does it now so i am unable to burn cds. Can anyone help?

  • I need to be able to right click on a saved document and have the option to convert to Adobe PDF. I have the Abobe Acrobat Xl Pro and used to have this option until I had to create a new subscription. What do I need to do in order to have this option?

    I need to be able to right click on a saved document and have the option to convert to Adobe PDF. I have the Abobe Acrobat Xl Pro and used to have this option until I had to create a new subscription. What do I need to do in order to have this option? I use windows 7

    If you are New to Mac... you may also find these links of Value
    Mac 101
    http://www.apple.com/support/mac101/
    http://www.apple.com/support/switch101/     Switching from PC
    MBP Support
    http://www.apple.com/support/macbookpro
    Cheers,

Maybe you are looking for

  • HT4623 How can I get Imessage back on my phone

    How can I get Imessage back on my phone

  • Actionscript 3 has abandoned me!!!

    I am fast losing patience with AS3....i thought it would help me until this point. I have a button which works when you first click it (to go to the next section). But if you wish to view the tech specs or copyright page and then go back and try and

  • How do I modify the file size

    I recently e-mailed a 1-page pdf document, converted from excel, that was 5.5 mb, whereas the original excel file was 50 kb. How does this happen, and how to correct this issue?

  • Audigy SE suspect in system cra

    I have an Audigy SE 7. card installed in a 450 meg ASUS system running Windows XP Professional and with specialist software the system crashes! ?After much consternation it has been found with Vienna that when a legitimate and well tested organ sound

  • WRE54G RANGE EXPANDER

    WOULD THIS RANGE EXPANDER WORK WITH ROUTER MODEL WAG54GS??