How to change the layout of an input file and write to an output file

Hi
I have a .csv file which has a layout as schoolNo. , county1,county2,county3,county4,county5
It will need to go into an output file as schoolNo. repeated and a county on each record .
ie., schoolNo.,county1
schoolNo.,county2
schoolNo.,county3
schoolNo.,county4
schoolNo.,county5
I wrote the java program as follows ..which results in this error
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
BECAUSE :--
i know bec., the first record doesnot have county3,county4,county5 . So when the if loop for county3 lenght is checked it gives this exception .
Pls help me write this program ..thanks in advance .
/Here I open the input file and read in record by record                                                                                                                        
          BufferedReader readin;
          try {
               readin = new BufferedReader(new FileReader(InFile));
               String firstLine = readin.readLine();
               String[] headers = firstLine.split(",");
               columnCount = headers.length;
               System.out.println("Columns in ZIP Master File: "+columnCount);
               for(String input ;(input = readin.readLine()) != null; ){
                    recCount++;
                    input = input.substring(1);               
                    String[] column = input.split(",");
                    if(columnCount == 10){
                         eachIP++;
//                               OUTPUT FILE
                                if(column[1].length()> 0) {
                                   String mainStr = column[0] + "," + column[1] ; 
                                   Count++;
                                   totalcolumns++;
                                   writeOutFile.write(mainStr);
                                   writeOutFile.newLine();
                              else{
                              bypassedCount++;
                                if(column[2].length()>0){
                                     String mainStr = column[0]+ "," + column[2];
                                     Count++;
                                     totalcolumns++;
                                   writeOutFile.write(mainStr);
                                   writeOutFile.newLine();
                              else{
                              bypassedCount++;
                                if(column[3]..length()>0){
                                     String mainStr = column[0]+ "," + column[3];
                                     Count++;
                                     totalcolumns++;
                                   writeOutFile.write(mainStr);
                                   writeOutFile.newLine();
                              else{
                              bypassedCount++;
                             }

There are two split( ... ) methods; check the other one (the one with two arguments), it allows for empty entries to be counted, i.e. split(inputString, -1) gives you the wanted results.

Similar Messages

  • How to change the layout of a category view

    I don't know how to change the layout of a category. I want to put 3 image's behind each other followed by some text, like a table with 4 columns. Instead of puting then in 4 rows

    larsprevo
    The category 'view' of items/folders uses the default style of the content area it is defined in (shared categories use the default shared style). Edit the default style to change the font/color of the items/folders returned within the category 'view'. Unfortunately, you don't have the ability to control the layout(like folder regions) - they always display in rows.
    Added an enhancement request for a feature that would allow you to control the display of items/folders in a category/perspective: 1828423

  • How to change the layout of the desktop before you login as a User into iPS.

    I am trying to change the layout of the anonymous user desktop. I know how to change the layout after i login as a User. All the thin channels except one get lined up in the first column of a thin-thick-thin layout.
    How to change that?
    Any help is greatly appreciated.
    Hugo Victor

    Go to available channel list and the select show advanced options, you should see the row and column attributes for the channel. Set it to your choice ..

  • How to change the value from one input control to another input control?

    Hi Experts,
    I want to change the value from  one input control to another input control. For Example if i change month in first tab. it should reflect in second tab also. How should we acheive through input control or some other option.
    Here I attached screen shot.Please help me for this

    Hi,
    It is not possible to have Input controll in all tabs that will be set from another .
    But There is one workaround .
    Follow the link below .
    http://davidlai101.com/blog/2013/08/13/web-intelligence-input-control-that-affects-all-tabs/

  • How 2 Change the Layout of Reports Paramform?

    reports 9.0.4.0.21
    hi folks
    we want to change the layout of the parameter form (html) on this way that it looks like our Corporate Design.
    (Logo, style, color, and so on)
    is it possible to change that design?
    if yes, how?
    thx in advance
    jogi

    Hello,
    http://download.oracle.com/docs/cd/B14099_17/bi.1012/b13895/orbr_howto.htm#i1039790
    3.11 Work with Parameters and the Parameter Form
    Regards

  • Export to Excel u0096 how to change the layout of the spreadsheet?

    Hello all,
    Do anyone knows how to configure the layout of the excel spreadsheet that opens when doing "export to Excel" from a web template report?
    For example, I would like to add texts or the filter values, how can I achieve it?
    Thank you!
    Ron.

    how can u add labels and texts in the exported excel sheet.
    as far as i know , NO U CANNOT DO THAT.
    cos watever data is displayed out of analysis web item that and only that u can output to excel websheet.
    as the analysis web item is assigned to excel output
    but if u want to output the texts and filter
    i can suggest
    create a tabbed pages
    in tab page assign filter section
    now in that tab page if u do export to excel the excel sheet will have filter output
    u cannot change that binding as far as i know..

  • How to change the layout of area pages in ESS Overview.

    Dear Experts,
    Area groups like Leave, directory,payslip are presented on portal in a layout which is fixed in backend ESS customization eg postions(1,2...).
    Can I change the layout of these areas in portal?
    I tried doing this by going to overview iview and preview and then ctrl+click. I could see containers for each area group but I could not modify their sequence?
    Please help!!!

    Hi,
    May be this guide can help you
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c0235c40-6351-2a10-a3a3-eb666dfdb407
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/10ddda33-277b-2a10-5294-9913ee5d698f
    Regards,
    Niraj
    Edited by: Niraj Kumar on Feb 18, 2009 10:26 AM

  • HT3625 How to change the audio port function (input, output) on OSX 10.9.2 !!!! :(

    The thing is that i saw some videos, and search for options of how to change the audio port.  And even apple says that i have to change it from system preferences, but when i try to change it, the option doesn't appear me.

  • How to change the layout of the ALV screen

    Hi,
    I need to have a parameter in the selection screen.  If I change the layout name on the selection-screen, the layout of the ALV needs to be changed.
    Thanks,
    srinivas.

    Pass the layout (and report name) to the ALV. parameter IS_VARIANT of function module [REUSE_ALV_GRID_DISPLAY|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=reuse_alv_grid_display&adv=false&sortby=cm_rnd_rankvalue] or method [SET_TABLE_FOR_FIRST_DISPLAY|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=set_table_for_first_display&adv=false&sortby=cm_rnd_rankvalue]
    You may also use the following function modules in your selection screen :
    - [REUSE_ALV_VARIANT_F4|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=reuse_alv_variant_f4&adv=false&sortby=cm_rnd_rankvalue]  to select the layout/variant name. (in AT SELECTION-SCREEN ON VALUE-REQUEST FOR <variant>.)
    - [REUSE_ALV_VARIANT_EXISTENCE|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=reuse_alv_variant_existence&adv=false&sortby=cm_rnd_rankvalue] to check existence of the layout/variant name.  (in AT SELECTION-SCREEN ON <variant>)
    - [REUSE_ALV_VARIANT_DEFAULT_GET|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=reuse_alv_variant_default_get&adv=false&sortby=cm_rnd_rankvalue] to get the default variant (to fill <variant> in the INITIALIZATION)
    Regards

  • How to change the "short name (account name?)" and home directory name?

    Hi,
    I recently purchased a new iMac and migrated account info from my MacBook Pro.  I happened to use random account name during migration without knowing it will not be easy to change the short name (account name?) and home directory name.  As a result, I am now having extremely confusing short name and home directory name on my new iMac.
    I did online search to find out how to change the two names, but I could only found somethig like "enabiling root user and....."  I have no idea what it was talking about and I don't want to take risk altering such advance set up manually.
    Please advice how I can change the short name and home directory name safely without much PC knowledge.
    Thank you very much in advance.

    There are a few ways of doing this. The easiest method is logging into the first account and copying everything to an external drive (or flash drive or whatever), which changes the permissions so that others can see the files.
    Then, login with the new account and copy the files over. Once they are copied, the correct permissions will be applied again (so other people on your computer can't access them).
    If you can't do this method for one reason or other, you can do some terminal commands to change the ownership of the files. Login to the new account. If it is an admin account, open terminal and type the following command:
    sudo chown -R -v yourusername:admin /Users/originalaccountnamehere
    That should change the ownership of the files from your old account to the new one. At that point, you can simply drag the files into place.

  • How to change the layout set for Search Results

    Hi gurus.
    I’m developing a search component for KM Search iView, and as a requirement the layout must change dynamically to display the search results.  How do I get this to happen?
    public SearchParamsMap getSearchParamsMap() {
         SearchParamsMap m = new SearchParamsMap();
              try {
              IQueryEntryList list =                   this.createQuery();
                   m.put(SearchParamConst.PARAM_SEARCH_QUERY_ENTRIES,                list);
              } catch (WcmException e) {
                   e.printStackTrace();
              m.put(
                   SearchParamConst.PARAM_SEARCH_IN,
                   SearchParamConst.SEARCH_FROM_FOLDER);
              m.put(SearchParamConst.PARAM_SEARCH_FOLDER, path);
              return m;
    private IQueryEntryList createQuery() throws WcmException {
              Hashtable searchParameters = new Hashtable();
              searchParameters.put(
                   SearchParamConst.PARAM_ITEMS_SELECTION,
                   SearchParamConst.ITEM_ONLY_DOCS);
              searchParameters.put(
                   SearchParamConst.RESULT_LAYOUT_SET,
                   "Sed_Comunicados");
              SearchQueryListBuilder sqb =
                   new SearchQueryListBuilder(searchParameters);
              IQueryEntryList qel = sqb.buildSearchQueryList();
              return qel;
    In the createQuery() method, code searchParameters.put(
                   SearchParamConst.RESULT_LAYOUT_SET,
                   "Sed_Comunicados"); is not working.  Also, where do I find the documentation for Class SearchParamConst?

    I have the same question.  Any help will be greatly appreciated.

  • How to change the layout of check in form

    Hi,
    Is there anyway to change to position of the metadata field, such as display more than one field in the same row?
    Thanks.

    Check out chapter 6 of the Admin Tutorials guide for some tips and tricks on using profiles and rules to change and enhance the layout and function of the checkin/search and other pages.
    http://download.oracle.com/docs/cd/E10316_01/cs/cs_doc_10/documentation/tutorials/tutorials_cserver_10en.pdf
    Warmly,
    Billy Cripe
    Fishbowl Solutions

  • How to get the value entered in input enabled field of a list output?

    Hi all,
    I am developing a program to display  list with two input enabled fields . After users enetered the values into these fields I need to do some calculations based on these values and modify the value of another field in the list.
    But i couldn't have an idea how to read the values after users enter into these fields.
    Please help me on solving this problem?  If possible please provide the sample code.
    Thanks,
    Aravind.

    You can enable disable screen fields in at selection screen output event.
    And by using loop at screen.
    And for changing the values you can do in initialization event.
    I Hope you are doing these in Reports.

  • How to change the text variables for a standard report-writer report ?

    I am trying to change the text variables for a report -writer report and transport the same so as to change the title page and the report output heading  .I know the Report-Group 6Z02 and the library 6O1 to which it belongs.I tried using the change transaction GR32 after going to the area menu through FGRP . I try to change the text variables through  but it throws an error "You chose a name in the reserved name range - try different name ".
    I have also tried copying this report into another report and changing the new report . I was able to change and save the text variables . Now when I try to overwrite the original report 6Z02-001 with this new report , it does not allow that.
    Let me know how I can change the text variables for the same

    Can anyone please suggest me what to do here ?

  • How to change the execution order of data control and backingbeans

    Hi,
    I have a form for a BPM human workflow. It has an inputText and a selectOneChoice component in the form.
    The list of value for the selectOneChoice is initiated based on the value in the inputText.
    I have a data control - JavaBean, which returns a list of values based on a parameter for the selectOneChoice and the parameter is binded with the value of inputText defined in a backingBean. I also set the default value of the inputBox in the backing bean with setValue().
    The problem I have is that the data control for selectOneChoice is loaded before the inputText or backingBean is loaded. Therefore, the parameter is null.
    I tested the same combination in an ADF web app and it works fine. In the app, the inputText and the backingBean are loaded first and then the value of inputText is sent to the data control.
    How can I change the order of the execution? I need to make the inputText and backingBean loading first before the data control for the list of values loading.
    Edited by: user626218 on Oct 10, 2012 9:25 PM

    Hi,
    The inputText is pre-populated based on the user profile in the BPM instance. I tried to render the selectOneChoice if the value of the inputText exists but the data control for selectOneChoice is loaded before the backingBean so it keeps getting a null as parameter.

Maybe you are looking for

  • 10.4.7 Install wont work

    I am re-installing 10.4.7 on my Intel Quad Tower - says there is a error and wants me to restart and try again - second time I had to do this. I have the drive partitioned with XP on the second partition. Do I need to clear that out too and start ove

  • Is Airport Express a router

    With all this information out there I can't seem to find a straight answer so maybe someone can help. Is the Airport Express a router with just one ethernet port, or is the point or a router that you can have more than one port. I am thinking of buy

  • A question for those who use tumblr app?

    I follow about 10 blogs, and when I look at my dashboard it is all a bunch of posts from each blog. Is there any way to see post from 1 specific blog on the app? Also can I browse for new blogs from the app or only on desktop version? Thanks for any

  • Confirmation du compte itunes store

    Bonsoir a tous quelqu'un peu me dire itunes confirmateur compte comment Mon je n'y parviens pas j'ai un message me disant que lun. disque et verrouillé ou que je n'ai pas d'autorisation Quelqu'un a (t il une solution merci d'avance

  • Video isn't playing anymore

    i am recently having a problem seeing my video when chatting, i can make a video, i can watch a video, but tonight when i was on Google + live a a chat, my video would not show. i invited a friend with a gmail account as i have, when i went to do vid