How to Design this Class while Reding a Csv File.

i[b] want to make this more Design orinted. This code is for reading A csv file and scnning it for Duplicate data in that Csv file.public Vector upLoadCsv(String csvFile) throws Exception
          boolean flag =false;
           Connection conn    = null;
         PreparedStatement  stmt    = null;
           Vector upload_data=new Vector();
           patternMapDescs = new Vector();
           patternFroms     = new Vector();
           patternTos     = new Vector();
           oprNetIds     = new Vector();
           circleIds     = new Vector();
           ldcaIds          = new Vector();
           sdcaIds          = new Vector();
     try{
          fileOut = new FileOutputStream(patrnBulkFailureFilePath, true);
          patternMapList=readFile(csvFile);
          System.out.println("PatternMapList is "+patternMapList); 
          Vector Patter_From=(Vector)patternMapList.get(0);
          Vector Pattern_To=(Vector)patternMapList.get(1);
          Vector Opr_Net_Id=(Vector)patternMapList.get(2);
          Vector Circle_Id=(Vector)patternMapList.get(3);
          Vector Ldca_Id=(Vector)patternMapList.get(4);
          Vector Sdca_Id=(Vector)patternMapList.get(5);
          Vector Msc_Id=(Vector)patternMapList.get(6);
          Vector Cell_Id=(Vector)patternMapList.get(7);
          Vector Pattern_Desc=(Vector)patternMapList.get(8);
          try
                    conn = DBHelper.getConnection();
                    System.out.println("Size is "+Patter_From.size());
                    for(int i=0;i<Patter_From.size();i++)
                         try
                         int result = 0;
                         System.out.println("Count value is "+i);
                         stmt = conn.prepareStatement("update lcorating.PATTERN_MAP set PATTERN_FROM=?,PATTERN_TO=?,OPR_NET_ID=?,CIRCLE_ID=?,LDCA_ID=?,SDCA_ID=?,MSC_ID=?,CELL_ID=?,PATTERN_DESC=? where pattern_from=? and pattern_to=?");                         
                         stmt.setString(1,(String)Patter_From.get(i));
                         stmt.setString(2,(String)Pattern_To.get(i));
                         stmt.setString(3,(String)Opr_Net_Id.get(i));
                         stmt.setString(4,(String)Circle_Id.get(i));
                         stmt.setString(5,(String)Ldca_Id.get(i));
                         stmt.setString(6,(String)Sdca_Id.get(i));
                         stmt.setString(7,(String)Msc_Id.get(i));
                         stmt.setString(8,(String)Cell_Id.get(i));
                         stmt.setString(9,(String)Pattern_Desc.get(i));
                         stmt.setString(10,(String)Patter_From.get(i));
                         stmt.setString(11,(String)Pattern_To.get(i));
                         result = stmt.executeUpdate();
                         System.out.println("result is "+result + "for "+(String)Patter_From.get(i));
          if(result==1)
                         upload_data.add((String)Patter_From.get(i));
                         upload_data.add((String)Pattern_To.get(i));
                         upload_data.add((String)Opr_Net_Id.get(i));
                         upload_data.add((String)Circle_Id.get(i));
                         upload_data.add((String)Ldca_Id.get(i));
                         upload_data.add((String)Sdca_Id.get(i));
                         upload_data.add((String)Msc_Id.get(i));
                         upload_data.add((String)Cell_Id.get(i));
                         upload_data.add((String)Pattern_Desc.get(i));
                         patternFroms.add((String)Patter_From.get(i));
                         patternTos.add((String)Pattern_To.get(i));
                         oprNetIds.add((String)Opr_Net_Id.get(i));
                         circleIds.add((String)Circle_Id.get(i));
                         ldcaIds.add((String)Ldca_Id.get(i));
                         sdcaIds.add((String)Sdca_Id.get(i));
                         patternMapDescs.add((String)Pattern_Desc.get(i));
                    if(result==0)
                         stmt = conn.prepareStatement("insert into lcorating.PATTERN_MAP values(?,?,?,?,?,?,?,?,?)");
                         stmt.setString(1,(String)Patter_From.get(i));
                         stmt.setString(2,(String)Pattern_To.get(i));
                         stmt.setString(3,(String)Opr_Net_Id.get(i));
                         stmt.setString(4,(String)Circle_Id.get(i));
                         stmt.setString(5,(String)Ldca_Id.get(i));
                         stmt.setString(6,(String)Sdca_Id.get(i));
                         stmt.setString(7,(String)Msc_Id.get(i));
                         stmt.setString(8,(String)Cell_Id.get(i));
                         stmt.setString(9,(String)Pattern_Desc.get(i));
                         stmt.executeUpdate();
upload_data.add((String)Patter_From.get(i));
upload_data.add((String)Pattern_To.get(i));
upload_data.add((String)Opr_Net_Id.get(i));
upload_data.add((String)Circle_Id.get(i));
upload_data.add((String)Ldca_Id.get(i));
upload_data.add((String)Sdca_Id.get(i));
upload_data.add((String)Msc_Id.get(i));
upload_data.add((String)Cell_Id.get(i));
upload_data.add((String)Pattern_Desc.get(i));
                         catch(Exception e)
                              System.out.println("Exception entry "+i);
                              String strFailure = (String)Patter_From.get(i) + ","+
                                                       (String)Pattern_To.get(i) + ","+
                                                       (String)Opr_Net_Id.get(i) + ","+
                                                       (String)Circle_Id.get(i) + ","+
                                                       (String)Ldca_Id.get(i) + ","+
                                                       (String)Sdca_Id.get(i) + ","+
                                                       (String)Msc_Id.get(i) + ","+
                                                       (String)Cell_Id.get(i) + ","+
                                                       (String)Pattern_Desc.get(i)+ "," + new java.util.Date()+ "\n";
                              System.out.println("writing "+ (String)Patter_From.get(i));
                              fileOut.write(strFailure.getBytes());
                              continue;
                    }catch(Exception e)
                         System.out.println("Excepion is "+e);                         
               flag=true;
               catch(Exception e)
               flag=false;
               System.out.println("Exception in Reading File===>"+e);
System.out.println("Uploaded data is ");
System.out.println(upload_data);
          return      upload_data;
// This method "readFile"  Reads the CSV file in the form of StringToken
private List readFile(String fileName)
          BufferedReader     br;
          String               record;
          StringTokenizer     st;
          Vector     vPatternFrom= new Vector();
          Vector vectorPatternFrom= new Vector();
          Vector vectorPatternTo= new Vector();
          Vector vectorOpertorNetworkId= new Vector();
          Vector vectorCircleId= new Vector();
          Vector vectorLdcaId= new Vector();
          Vector vectorSdcaId= new Vector();
          Vector vectorMscId= new Vector();
          Vector vectorCellId= new Vector();
          Vector vectorPatternDesc= new Vector();
          ArrayList totalList=new ArrayList();
          boolean isExist=false;
           boolean duplicateOrgNUmFlag=false;
          try
               br = new BufferedReader(new InputStreamReader(new FileInputStream(fileName)));
               while ((record = br.readLine()) != null)
                    st = new StringTokenizer(record,",");
                    try
                         while (st.hasMoreTokens())
                              vPatternFrom.add(st.nextToken());
                              vPatternFrom.add(st.nextToken());
                              vPatternFrom.add(st.nextToken());
                              vPatternFrom.add(st.nextToken());
                              vPatternFrom.add(st.nextToken());
                              vPatternFrom.add(st.nextToken());
                              vPatternFrom.add(st.nextToken());
                              vPatternFrom.add(st.nextToken());
                              vPatternFrom.add(st.nextToken());     
                    catch(NoSuchElementException nseex)
                         System.out.println("Record without valid data :: " + record);
          catch(FileNotFoundException fnfex)
               System.out.println("exception is"+fnfex.toString());
          catch (IOException ioex)
               System.out.println("exception is"+ioex.toString());
          catch(Exception e){
               System.out.println("praveen is stupid");
          System.out.println("vPatternFrom"+vPatternFrom);
          int noOfRecords = vPatternFrom.size();
          //System.out.println("Size of record is "+noOfRecords);
          for(int i=0;i<vPatternFrom.size();i=i+9)
                    String sPatternFrom=(String)vPatternFrom.get(i);
                    vectorPatternFrom.add(sPatternFrom);
                    String sPatternTo     =(String)vPatternFrom.get(i+1);
                    vectorPatternTo.add(sPatternTo);
                    String sOpertorNetworkId=(String)vPatternFrom.get(i+2);
                    vectorOpertorNetworkId.add(sOpertorNetworkId);
                    String sCircleId=(String)vPatternFrom.get(i+3);
                    vectorCircleId.add(sCircleId);
                    String sLdcaId=(String)vPatternFrom.get(i+4);     
                    vectorLdcaId.add(sLdcaId);
                    String sSdcaId=(String)vPatternFrom.get(i+5);
                    vectorSdcaId.add(sSdcaId);     
                    String sMscId=(String)vPatternFrom.get(i+6);
                    vectorMscId.add(sMscId);
                    String sCellId=(String)vPatternFrom.get(i+7);
                    vectorCellId.add(sCellId);
                    String sPatternDesc =(String)vPatternFrom.get(i+8);
                    vectorPatternDesc.add(sPatternDesc);
     totalList.add(vectorPatternFrom);
     totalList.add(vectorPatternTo);
     totalList.add(vectorOpertorNetworkId);
     totalList.add(vectorCircleId);
     totalList.add(vectorLdcaId);
     totalList.add(vectorSdcaId);
     totalList.add(vectorMscId);
     totalList.add(vectorCellId);
     totalList.add(vectorPatternDesc);
ArrayList rrList=new ArrayList();
try{
          rrList=verifyTotalPatternData(totalList);
}catch(Exception e){
     System.out.println("excpetion is bothering");
          return rrList;
public ArrayList verifyTotalPatternData(ArrayList totalList)
          Vector pattern_from=(Vector)totalList.get(0);
          Vector pattern_to=(Vector)totalList.get(1);
          Vector opr_net_id=(Vector)totalList.get(2);
          Vector circle_id=(Vector)totalList.get(3);
          Vector ldca_id=(Vector)totalList.get(4);
          Vector sdca_id=(Vector)totalList.get(5);
          Vector msc_id=(Vector)totalList.get(6);
          Vector cell_id=(Vector)totalList.get(7);
          Vector pattern_desc=(Vector)totalList.get(8);
          String strFailure = "";
          for(int i=0;i<pattern_from.size();i++){
               for(int j=i+1;j<pattern_from.size();j++){
                    if((pattern_from.get(j)).equals(pattern_from.get(i))){
                         if((pattern_to.get(j)).equals(pattern_to.get(i))){
                              try{
                              strFailure=(String)pattern_from.get(i) + ","+
                                             (String)pattern_to.get(i) + ","+
                                             (String)opr_net_id.get(i) + ","+
                                             (String)circle_id.get(i) + ","+
                                             (String)ldca_id.get(i) + ","+
                                             (String)sdca_id.get(i) + ","+
                                             (String)msc_id.get(i) + ","+
                                             (String)cell_id.get(i) + ","+
                                             (String)pattern_desc.get(i) + "," + new java.util.Date()+"\n";
                              //System.out.println("writing "+ (String)pattern_from.get(i));
                              fileOut.write(strFailure.getBytes());
                              catch(Exception e)
                                   System.out.println("Exception while adding entry in bulkFailureData.csv "+e);
                              pattern_from.removeElementAt(j);
                              pattern_to.removeElementAt(j);
                              opr_net_id.removeElementAt(j);
                              circle_id.removeElementAt(j);
                              ldca_id.removeElementAt(j);
                              sdca_id.removeElementAt(j);
                              msc_id.removeElementAt(j);
                              cell_id.removeElementAt(j);
                              pattern_desc.removeElementAt(j);
                              j--;
          ArrayList ret_list = new ArrayList();
          ret_list.add(pattern_from);
          ret_list.add(pattern_to);
          ret_list.add(opr_net_id);
          ret_list.add(circle_id);
          ret_list.add(ldca_id);
          ret_list.add(sdca_id);
          ret_list.add(msc_id);
          ret_list.add(cell_id);
          ret_list.add(pattern_desc);
          //System.out.println("The filtered list is "+ret_list);
          return ret_list;
     }

I was bored, so I took a stab at cleaning your code up a bit. You need
to take advantage of the Collections API, and you desparately
need to learn how to use data structures. Some would argue
that my get???Statement methods are really bad, fyi. They might
very well be right -- it's hard to tell from the few methods provided.
You should also take a serious look at Log4j, or at least the
java standard logger.
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.Vector;
public class Foo {
    private final FileOutputStream fileOut;       
    public Foo() throws FileNotFoundException {
        this.fileOut = new FileOutputStream(patrnBulkFailureFilePath, true);
    public Set uploadCsv(final String csvFile) {
        final Set uploadedData = new HashSet();
        Connection conn = null;
        Vector upload_data = new Vector();
        final Collection patternDataSet = this.readFile(csvFile);
        try {
            conn = DBHelper.getConnection();
            for (final Iterator i = patternDataSet.iterator(); i.hasNext(); ) {
                final PatternData patternData = (PatternData) i.next();
                final PreparedStatement updateStatement =
                    patternData.getUpdateStatement(conn);
                try {
                    final int result = updateStatement.executeUpdate();
                    if (result == 1) {
                        uploadedData.add(patternData);
                    if (result == 0) {
                        final PreparedStatement insertStatement =
                            patternData.getInsertStatement(conn);
                        insertStatement.executeUpdate();
                        uploadedData.add(patternData);
                } catch (final SQLException se) {
                    final String errorMsg =
                        patternData.toString() + "," +
                        System.currentTimeMillis();
                    this.fileOut.write(errorMsg.getBytes());
        } catch (final SQLException se) {
            System.err.println("Unexpected SQL Exception");
            se.printStackTrace(System.err);
        return uploadedData;
    private Collection readFile(final String fileName) {
        final FileReader fileReader;
        final BufferedReader bufferedReader;
        final Set patternData = new HashSet();
        try {
            fileReader = new FileReader(fileName);
            bufferedReader = new BufferedReader(fileReader);
            while (bufferedReader.ready()) {
                final String dataLine = bufferedReader.readLine();
                final String[] values = dataLine.split(",");
                final PatternData data = new PatternData(values);
                if (patternData.contains(data)) {
                    final String errorMsg =
                        data.toString() + "," + System.currentTimeMillis();
                    this.fileOut.write(errorMsg.getBytes());                   
                } else {
                    patternData.add(new PatternData(values));
        } catch (final FileNotFoundException fnfe) {
            System.err.println("Unable to locate file: " + fileName);
        } catch (final IOException ioe) {
            System.err.println("Unexpected IO Exception");
            ioe.printStackTrace(System.err);
        return patternData;
    private static class PatternData {
        private final String patternFrom;
        private final String patternTo;
        private final String oprNetID;
        private final String circleID;
        private final String ldcaID;
        private final String sdcaID;
        private final String mscID;
        private final String cellID;
        private final String patternDesc;
        public PatternData(final String patternFrom, final String patternTo,
                final String oprNetID, final String circleID, final String
                ldcaID, final String sdcaID, final String mscID,
                final String cellID, final String patternDesc) {
            this.patternFrom = patternFrom;
            this.patternTo = patternTo;
            this.oprNetID = oprNetID;
            this.circleID = circleID;
            this.ldcaID = ldcaID;
            this.sdcaID = sdcaID;
            this.mscID = mscID;
            this.cellID = cellID;
            this.patternDesc = patternDesc;
        public PatternData(final String[] dataValues)
        throws IllegalArgumentException {
            if (dataValues == null) {
                throw new IllegalArgumentException("The dataValues " +
                        "parameter may not be null.");
            if (dataValues.length != 9) {
                throw new IllegalArgumentException("The dataValues parameter " +
                        "must have a length of 9, not " + dataValues.length);
            this.patternFrom = dataValues[0];
            this.patternTo = dataValues[1];
            this.oprNetID = dataValues[2];
            this.circleID = dataValues[3];
            this.ldcaID = dataValues[4];
            this.sdcaID = dataValues[5];
            this.mscID = dataValues[6];
            this.cellID = dataValues[7];
            this.patternDesc = dataValues[8];
        public boolean equals(final Object obj) {
            if (this == obj) {
                return true;
            if (!(obj instanceof PatternData)) {
                return false;
            final PatternData otherData = (PatternData) obj;
            if (this.patternFrom.equals(otherData.patternFrom) &&
                    this.patternTo.equals(otherData.patternTo)) {
                return true;
            return false;
        public int hashCode() {
            int hash = 17;
            hash = 37 * hash + this.patternFrom.hashCode();
            hash = 37 * hash + this.patternTo.hashCode();
            return hash;
        public String toString() {
            return this.patternFrom + "," + this.patternTo + "," +
                 this.oprNetID + "," + this.circleID + "," +
                 this.ldcaID + "," + this.sdcaID + "," + this.mscID + "," +
                 this.cellID + "," + this.patternDesc;
        public PreparedStatement getUpdateStatement(final Connection conn)
        throws SQLException {
            final PreparedStatement statement =
                conn.prepareStatement("update lcorating.PATTERN_MAP set " +
                        "PATTERN_FROM=?,PATTERN_TO=?,OPR_NET_ID=?," +
                        "CIRCLE_ID=?,LDCA_ID=?,SDCA_ID=?,MSC_ID=?,CELL_ID=?" +
                        ",PATTERN_DESC=? where pattern_from=? and " +
                        "pattern_to=?");                                  
            statement.setString(1, this.patternFrom);
            statement.setString(2, this.patternTo);
            statement.setString(3, this.oprNetID);
            statement.setString(4, this.circleID);
            statement.setString(5, this.ldcaID);
            statement.setString(6, this.sdcaID);
            statement.setString(7, this.mscID);
            statement.setString(8, this.cellID);
            statement.setString(9, this.patternDesc);
            statement.setString(10, this.patternFrom);
            statement.setString(11, this.patternTo);
            return statement;
        public PreparedStatement getInsertStatement(final Connection conn)
        throws SQLException {
            final PreparedStatement statement =
                conn.prepareStatement("insert into lcorating.PATTERN_MAP " +
                        "values(?,?,?,?,?,?,?,?,?)");
            statement.setString(1, this.patternFrom);
            statement.setString(2, this.patternTo);
            statement.setString(3, this.oprNetID);
            statement.setString(4, this.circleID);
            statement.setString(5, this.ldcaID);
            statement.setString(6, this.sdcaID);
            statement.setString(7, this.mscID);
            statement.setString(8, this.cellID);
            statement.setString(9, this.patternDesc);
            return statement;
}

Similar Messages

  • How to skip first records while reading a csv file

    Hi,
    How to skip the first 5 records while reading csv file.
    I have a file which contains first 5 records as dummy records, I want to skip those records and load the rest into RDBMS.
    How to achieve this?
    Thanks,
    Naveen Suram

    Hi Guru,
    Actually I have converted an excel to CSV format, which is generating first 4 rows as some dummy records. 5th row is my header record. But in hearder record, two column names are same. Thats why while reversing it is giving an error.
    With zero in number of columns in header, I am getting the column names as C1, C2...
    If not in reversing, can we reject the first records while loading into RDMBS table using an interface?
    Thanks,
    Naveen Suram

  • HT3743 HT4623 We're sorry, we are unable to continue with your activation at this time. Please try again later, or contact customer care.----How to fix this issue while setting up the iphone for the new ios?

    HT4623 We're sorry, we are unable to continue with your activation at this time. Please try again later, or contact customer care.----How to fix this issue while setting up the iphone for the new ios?

    If you don't have a SIM card in the phone, you must put one in. It's required for activation.
    If you do, then your phone was probably hacked to unlock it from the original carrier. Contact them and see if they will unlock it. If they will not do so, then you can't use that phone.

  • How to write the JTables Content into the CSV File.

    Hi Friends
    I managed to write the Database records into the CSV Files. Now i would like to add the JTables contend into the CSV Files.
    I just add the Code which Used to write the Database records into the CSV Files.
    void exportApi()throws Exception
              try
                   PrintWriter writing= new PrintWriter(new FileWriter("Report.csv"));
                   System.out.println("Connected");
                   stexport=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
                   rsexport=stexport.executeQuery("Select * from IssuedBook ");
                   ResultSetMetaData md = rsexport.getMetaData();
                   int columns = md.getColumnCount();
                   String fieldNames[]={"No","Name","Author","Date","Id","Issued","Return"};
                   //write fields names
                   String rec = "";
                   for (int i=0; i < fieldNames.length; i++)
                        rec +='\"'+fieldNames[i]+'\"';
                        rec+=",";
                   if (rec.endsWith(",")) rec=rec.substring(0, (rec.length()-1));
                   writing.println(rec);
                   //write values from result set to file
                    rsexport.beforeFirst();
                   while(rsexport.next())
                        rec = "";
                         for (int i=1; i < (columns+1); i++)
                             try
                                    rec +="\""+rsexport.getString(i)+"\",";
                                    rec +="\""+rsexport.getInt(i)+"\",";
                             catch(SQLException sqle)
                                  // I would add this System.out.println("Exception in retrieval in for loop:\n"+sqle);
                         if (rec.endsWith(",")) rec=rec.substring(0,(rec.length()-1));
                        writing.println(rec);
                   writing.close();
         }With this Same code how to Write the JTable content into the CSV Files.
    Please tell me how to implement this.
    Thank you for your Service
    Jofin

    Hi Friends
    I just modified my code and tried according to your suggestion. But here it does not print the records inside CSV File. But when i use ResultSet it prints the Records inside the CSV. Now i want to Display only the JTable content.
    I am posting my code here. Please run this code and find the Report.csv file in your current Directory. and please help me to come out of this Problem.
    import javax.swing.*;
    import java.util.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.table.*;
    public class Exporting extends JDialog implements ActionListener
         private JRadioButton rby,rbn,rbr,rbnore,rbnorest;
         private ButtonGroup bg;
         private JPanel exportpanel;
         private JButton btnExpots;
         FileReader reading=null;
         FileWriter writing=null;
         JTable table;
         JScrollPane scroll;
         public Exporting()throws Exception
              setSize(550,450);
              setTitle("Export Results");
              this.setLocation(100,100);
              String Heading[]={"BOOK ID","NAME","AUTHOR","PRICE"};
              String records[][]={{"B0201","JAVA PROGRAMING","JAMES","1234.00"},
                               {"B0202","SERVLET PROGRAMING","GOSLIN","1425.00"},
                               {"B0203","PHP DEVELOPMENT","SUNITHA","123"},
                               {"B0204","PRIAM","SELVI","1354"},
                               {"B0205","JAVA PROGRAMING","JAMES","1234.00"},
                               {"B0206","SERVLET PROGRAMING","GOSLIN","1425.00"},
                               {"B0207","PHP DEVELOPMENT","SUNITHA","123"},
                               {"B0208","PRIAM","SELVI","1354"}};
              btnExpots= new JButton("Export");
              btnExpots.addActionListener(this);
              btnExpots.setBounds(140,200,60,25);
              table = new JTable();
              scroll=new JScrollPane(table);
              ((DefaultTableModel)table.getModel()).setDataVector(records,Heading);
              System.out.println(table.getModel());
              exportpanel= new JPanel();
              exportpanel.add(btnExpots,BorderLayout.SOUTH);
              exportpanel.add(scroll);
              getContentPane().add(exportpanel);
              setVisible(true);
          public void actionPerformed(ActionEvent ae)
              Object obj=ae.getSource();
              try {
              PrintWriter writing= new PrintWriter(new FileWriter("Report.csv"));
              if(obj==btnExpots)
                   for(int row=0;row<table.getRowCount();++row)
                             for(int col=0;col<table.getColumnCount();++col)
                                  Object ob=table.getValueAt(row,col);
                                  //exportApi(ob);
                                  System.out.println(ob);
                                  System.out.println("Connected");
                                  String fieldNames[]={"BOOK ID","NAME","AUTHOR","PRICE"};
                                  String rec = "";
                                  for (int i=0; i <fieldNames.length; i++)
                                       rec +='\"'+fieldNames[i]+'\"';
                                       rec+=",";
                                  if (rec.endsWith(",")) rec=rec.substring(0, (rec.length()-1));
                                  writing.println(rec);
                                  //write values from result set to file
                                   rec +="\""+ob+"\",";     
                                   if (rec.endsWith(",")) rec=rec.substring(0,(rec.length()-1));
                                   writing.println(rec);
                                   writing.close();
         catch(Exception ex)
              ex.printStackTrace();
         public static void main(String arg[]) throws Exception
              Exporting ex= new Exporting();
    }Could anyone Please modify my code and help me out.
    Thank you for your service
    Cheers
    Jofin

  • Error while loading a CSV file

    Haii,
    While loading a csv file in Open Script I'm facing with the foll: error.
    Error loading the CSV file Caused by: java.io.SocketException occurred.
    Can anyone please help me sort it out.
    Thank You

    Hi,
    Are you creating a table and loading it in Openscript??
    If so, can you show the screen shot.
    One more information , you can also change the Excel sheet into a CSV file and you can add it as a databank in the Tree view of the Openscript.
    Thanks and Regards,
    Nishanth Soundararajan.

  • How to design this report ?

    Hi experts,
    How to design the customer total outstanding report as on a particular date ?
    We also want Debit amount and Credit amount in the query output..
    Regards,
    Nishuv V.

    HI,
    if u want the current date u go for the customer exit (that means daily)if he wants aparticular date then u go for the user entry variable in 0calday,in variable screen he sould mention the date for that date only the out standing report will come .0calday and customer u keep in rows and those debit and credit u keep in the columns.
    if daily as on date they want outstanding u go for the customer exit just u create the variable on 0calday with customer exit if variable name is 'zcedate' go to the tcode CMOD and write the below mention code.
    when 'zcedate'.
    clear l_s_range.
    l_s_range-sign = 'i'.
    l_s_range-opt = 'eq'.
    l_s_range-low = sy-datum.
    append l_s_range to e_t_range.
    Thanks  for giving this opportunity.
    Thanks & Regards
    k.sathish

  • How to design this BO?

    This picture shows the result which I want ,however,I don't konw how to design the BO! Can anybody help me ?
    Best Regards!

    Hi,
    Have a main view with 3 viewcontainer ui elements. Have 3 more views, with each control in the view. Have 3 attributes defined in a node of the component controller, one each for the tree selection, ALV selection and button enabling. All these attributes will be of type char01. Map the component controller node to all your view nodes.
    In the click event of the tree, set the first attribute. In the click event of the ALV, set the second attribute. In the wddoinit of the 3rd view, do a get_attribute to see if both the previous attributes are 'X'. Then do a set_attribute of the 3rd one. Bind the 3rd attribute to the 'Enabled' property of the button. By default it will be greyed out.
    But why do you need each control in a separate view? You could very well place them in transparent containers or some other element inside the same view right? From your description, I dont really see a need for separate views.
    Hope this helps.
    Regards,
    Nithya

  • How to design this complex report

    I'm getting crazy======
    my mdb file is like this.
    For example, "PointName" has many pointname, like C1, C2, C3..........,[they are vertical tunnels].
    For every point/tunnel, like C1,
    we mearsure it every few days, and get the displacement with the depth.
    Point C1 ---- 2014/2/19 ---- depth: -1 ---- it's displacement is 0.4
    And for the report, I want every point have a crosstab and graph.
    How to do this report, many thanks!!!

    Hi, Jamie
    I think I haven't say it clear. The final report is all C1 in one crosstab, all C2 in one crosstab.......this is the key.
    I followed as you say, it shows, there are many c1 and c2, and the crosstab is wrong.
    Then I tried to use subreport
    it shows
    I want one C1 and one C2 and so on, and all C1's data in one crosstab and all C2's data in one crosstab.
    That's it.
    A'm I clear? If not, please tell me. Thanks.

  • How to register for class while using ActiveX

    Hi
    I am trying to use ActiveX to send an email with Microsoft Outlook. I have found an example Vi. but i was getting an error with code "-2147221164" (Class not registered in Outlook_Mail-1.vi). How to register for that class and what are the files required for that registration.
    Attachments:
    Outlook_Mail-1.vi ‏31 KB

    Here is a picture of the Photosmart eStation:
    Don't forgot to say thanks by giving "Kudos" if I helped solve your problem.
    When a solution is found please mark the post that solves your issue.
    Every problem has a solution!

  • How do I reinstall Yosemite while keeping my personal files & settings?

    Hi,
    I am running Yosemite (10.10.2) on my 2013 Macbook Air and its in need of some love. Most notably, my Notes app has broken (it crashes on every attempt to open it) and my bluetooth has gone haywire (device detection and personal hotspot works when they feel like it), my display will randomly go black and is becoming an increasingly mysterious and lengthy process to get it back (normally just mashing keys and opening and closing the lid several times over). Thats just the half of it.
    I want to say the mass majority of these issues began after signing myself up to receive all these alpha, beta, omega, apple tree pre-seed, under-cooked releases or whatever apple pushes down the pipeline. Needless to say, I feel its time to reinstall my OS though I am quickly discovering that this whole process was significantly easier in a Windows environment which seems really counter-intuitive considering well, this is Apple and things are just supposed to work like magical butter.
    So I ended up reinstalling Yosemite through the Recovery Utility (CMD+R). It downloaded from the internet and installed. My personal files were kept intact but it didn't fix my Notes app as it still kept quitting unexpectedly when trying to launch it. So I opted to perform a clean install. I quickly realized this was a TERRIBLE idea as I was unable to recover important settings like my keychain passwords, my email accounts and so forth. Thankfully I made a time machine backup before attempting any of this so I am right back where I started (sort of).
    I need some help please.
    My goal is to perform a clean install of Yosemite to rid myself of these OS oddities meanwhile keeping everything important. This includes, most notably:
    my personal document, photo and music files
    my iTunes library
    my iPhoto library (and more importantly, the settings, albums tags, image edits etc etc) that I've made over the years
    my keychain passwords
    my email accounts (it took me almost an hour to setup and properly configure all 9 of my email accounts and i don't want to go through that again)
    my calendar and events within it
    Other settings I would like to keep, but am willing to sacrifice are:
    my iMessage history
    my applications
    my user experience settings; things like the dock size and behaviour, track pad scroll speed etc etc etc. I'm on the fence with this one since I've plugged in so much sudo code into terminal trying to accomplish things in the past, that I fear theres some settings that shouldn't be restored.
    So Apple community, what say thee; what is my best course of action?
    Thank you,
    -Brendon

    Oh boy... throughout all of this i think I've really done a number. In trying to execute the instructions in the link you provided, I receive this error while trying to access my internet accounts panel under system preferences:
    "Preferences Error
    Could not load Internet Accounts preference pane."
    What have I done lol...

  • How can I email using UTL_SMTP with a csv file as an attachment?

    Dear All,
    It would be great if someone could help me. I am trying to use UTL_SMTP to email with a csv file as attachment. I do get an email with a message but no attachment arrives with it.
    In fact the code used for attaching the csv file gets appended in the message body in the email.
    CREATE OR REPLACE PROCEDURE test_mail
    AS
    SENDER constant VARCHAR2(80) := '[email protected]';
    MAILHOST constant VARCHAR2(80) := 'mailhost.xxxx.ac.uk';
    mail_conn utl_smtp.connection;
    lv_rcpt VARCHAR2(80);
    lv_mesg VARCHAR2(9900);
    lv_subject VARCHAR2(80) := 'First Test Mail';
    lv_brk VARCHAR2(2) := CHR(13)||CHR(10);
    BEGIN
    mail_conn := utl_smtp.open_connection(mailhost, 25) ;
    utl_smtp.helo(mail_conn, MAILHOST) ;
    dbms_output.put_line('Sending Email to : ' ||lv_brk||'Suhas Mitra' ) ;
    lv_mesg := 'Date: '||TO_CHAR(sysdate,'dd Mon yy hh24:mi:ss')||lv_brk||
    'From: <'||SENDER||'>'||lv_brk||
    'Subject: '||lv_subject||lv_brk||
    'To: '||'[email protected]'||lv_brk||
    'MIME-Version: 1.0'||lv_brk||
    'Content-type:text/html;charset=iso-8859-1'||lv_brk||
    ' boundary="-----SECBOUND"'||
    ''||lv_brk||
    '-------SECBOUND'||
    'Some Message'
              || lv_brk ||
    '-------SECBOUND'||
              'Content-Type: text/plain;'|| lv_brk ||
              ' name="xxxx.csv"'|| lv_brk ||
              'Content-Transfer_Encoding: 8bit'|| lv_brk ||
              'Content-Disposition: attachment;'|| lv_brk ||
              ' filename="xxxx.csv"'|| lv_brk ||
              lv_brk ||
    'CSV,file,attachement'|| lv_brk ||     -- Content of attachment
    lv_brk||
    '-------SECBOUND' ;
    dbms_output.put_line('lv_mesg : ' || lv_mesg) ;
    utl_smtp.mail(mail_conn, SENDER) ;
    lv_rcpt := '[email protected]';
    utl_smtp.rcpt(mail_conn, lv_rcpt) ;
    utl_smtp.data(mail_conn, lv_mesg) ;
    utl_smtp.quit(mail_conn);
    EXCEPTION
    WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
    NULL ;
    WHEN OTHERS THEN
    dbms_output.put_line('Error Code : ' || SQLCODE) ;
    dbms_output.put_line('Error Message : ' || SQLERRM) ;
    utl_smtp.quit(mail_conn) ;
    END;

    LKBrwn_DBA wrote:
    Use UTL_MAIL instead.That package is an utter disappointment - and an excellent example IMO of how not to design an application programming interface. Even the source code is shoddy.. I mean, having to resort to a GOTO statement....!!?? The person(s) who wrote that package are sorely lacking in even the most basic of programming skills if structured programming is ignored and a spaghetti command used instead.
    No wonder the public interface of that code is equally shabby and thoughtless... The mail demo code posted by Oracle was better written than this "+package+" they now have bundled as the official Mail API.
    I dunno.. if I was in product management there would have been hell to pay over pushing cr@p like that to customers.

  • How can we export table data to a CSV file??

    Hi,
    I have the following requirement. Initially business agreed upon, exporting the table data to Excel file. But now, they would like to export the table data to a CSV file, which is not being supported by af:exportCollectionActionListener component.
    Because, when i opened the exported CSV file, i can see the exported data sorrounded with HTML tags. Hence the issue.
    Does someone has any solution for this ... Like, how can we export the table data to csv format. And it should work similar to exporting the data to excel sheet.
    For youre reference here is the code which i have used to export the table data..
    ><f:facet name="menus">
    ><af:menu text="Menu" id="m1">
    ><af:commandMenuItem text="Print" id="cmi1">
    ><af:exportCollectionActionListener exportedId="t1"
    >title="CommunicationDistributionList"
    >filename="CommunicationDistributionList"
    >type="excelHTML"/> ---- I tried with removing value for this attribute. With no value, it did not worked at all.
    ></af:commandMenuItem>
    ></af:menu>
    ></f:facet>
    Thanks & Regards,
    Kiran Konjeti

    Hi Alex,
    I have already visited that POST and it works only in 10g. Not in 11g.
    I got the solution for this. The solution is :
    Use the following code in jsff
    ==================
    <af:commandButton text="Export Data" id="ctb1">><af:fileDownloadActionListener contentType="text/csv; charset=utf-8"
    >filename="test.csv"
    >method="#{pageFlowScope.pageFlowScopeDemoAppMB.test}"/>
    ></af:commandButton>
    OR
    <af:commandButton text="Export Data" id="ctb1">><af:fileDownloadActionListener contentType="application/vnd.ms-excel; charset=utf-8"
    >filename="test.csv"
    >method="#{pageFlowScope.pageFlowScopeDemoAppMB.test}"/>
    ></af:commandButton>
    And place this code in ManagedBean
    ======================
    > public void test(FacesContext facesContext, OutputStream outputStream) throws IOException {
    > DCBindingContainer dcBindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    >DCIteratorBinding itrBinding = (DCIteratorBinding)dcBindings.get("fetchDataIterator");
    >tableRows = itrBinding.getAllRowsInRange();
    preparaing column headers
    >PrintWriter out = new PrintWriter(outputStream);
    >out.print(" ID");
    >out.print(",");
    >out.print("Name");
    >out.print(",");
    >out.print("Designation");
    >out.print(",");
    >out.print("Salary");
    >out.println();
    preparing column data
    > for(Row row : tableRows){
    >DCDataRow dataRow = (DCDataRow)row;
    > DataLoaderDTO dto = (DataLoaderDTO)dataRow.getDataProvider();
    >out.print(dto.getId());
    >out.print(",");
    >out.print(dto.getName());
    >out.print(",");
    >out.print(dto.getDesgntn());
    >out.print(",");
    >out.print(dto.getSalary());
    >out.println();
    >}
    >out.flush();
    >out.close();
    > }
    And do the following settings(*OPTIONAL*) for your browser - Only in case, if the file is being blocked by IE
    ==================================================================
    http://ais-ss.usc.edu/helpdoc/main/browser/bris004b.html
    This resolves implementation of exporting table data to CSV file in 11g.
    Thanks & Regards,
    Kiran Konjeti

  • How do I get the data in the CSV file to be in the same order as the form?

    When I merge my data from multiple form submissions into a csv file, the data is completely out of order, which makes it pretty much useles. How can I make it export the data in the same order? Also, the headers of each column or garbled. For example:
    Depth (mm) shows in excel as Depth__mm__aqWhxx1nhpwx*3sgoBx9UQ
    Lesion Location with check boxes: Face, Scalp, Trunk shows as each individual: Lesion_Location_1_15w4B5z9Kg2FKrkCPa6Wvg or Lesion_Location_3_15w4B5z9Kg2FKrkCPa6Wvg.
    What I want is for the data produced to be in the same order as the form and with the same headers.
    Also, I created several help texts that don't appear in the form.
    I'd be happy to upload any of the files (form template, form pdf, csv file) if there is a way to.
    I used Adobe Forms Central to create the forms in Acrobat XI Pro. I'm on a windows 7 computer.
    Thank you for your help

    Some of this is just the way it is with a PDF form created with FormsCentral. The fields get those names to ensure that they are unique, since the FormsCentral designer app does not allow yo to specify the field names directly. A fixt would be to create the form in Acrobat and you can give the fields any name you want. You can also change the field names in Acrobat after first removing the usage rights from the PDF by selecting: File > Save a Copy
    and renaming the fields to what you want. Also remove the submit button it added. You can then upload the edited PDF to FormsCentral and Distribute it. It looks as though the order of the fields in the table are alphabetical, so it you rename your fields so they will be in the order you want when arranged alphabetically (e.g., A1_Patient_ID, A2_Biopsy_Age, etc.), that might be an approach to take. Also, if this is for human patient data, check for regulatory compliance of this system. FormsCentral is specifically not HIPAA compliant as stated in the license agreement.

  • Trigger while importing from .csv file

    hey
    i am importing data from .csv file into a table called temp.
    .csv file is having column sales. the data in that also contains some empty filed or N/A or -
    sales coulmn in my table is NUMBER.
    so while importing some column are not able to import.
    how to write a trigger to eliminate '-' or 'N/A' or ' ' values from the sales column before inserting into the table

    It might be easier if the field on temp was a varchar2 field instead?
    The values entered should be loaded into this field and you can then use the trigger to test the values and convert these into numbers or nulls before inserting onto the proper data table.
    Check out the TO_NUMBER() function in SQL for info on how to convert strings to numbers.
    Regards
    Andy

  • How to update Records of SAP table from .CSV file

    Hi,
    I have written a code which takes a data from (,) delimited CSV file and adds it into the Internal table.
    Now I want to update the all fields in SAP table with the Internal table.
    I want to use Update statement.
    Update <table Name> SET <field needs to update> WHERE connditon.
    I don't want to iterate through thousand on record in sap table to check the where condition.
    Could you please tell me how to do it.

    Hi. I thing you will not workaround the iterating of the internal table.
    You can pre-load all the records into another internal table
    check lt_csv[] is not initial. " important, otherwise next select would read all records of the table
    select .... into lt_dbitab for all entries in lt_csv where key-fieds = lt_csv-key_fields...
    check sy-subrc eq 0 and lt_dbitab[] is not initial.
    then do in-memory update of the it_dbitab
    loop at it_dbitab assign <fs>.
      read table lt_csv assign <fs_csv> with key ... " lt_csv should be sorted table with key, or you should try to use binary search
      if sy-subrc eq 0.
        ...change required lt_dbitab fields: <fs>-comp = <fs_csv>-comp...
      endif.
    endloop.
    ant then you can do mass-update
    update dbtab from table lt_dbitab.
    From performance view, this solution should be much faster than iterating lt_csv directly and updating every single database record
    Br
    Bohuslav

Maybe you are looking for

  • Calendar date & net due date (FI) PAYMENT TERMS - OBB8 Vendor Invoice

    I read many posts on SDN forum about the topic. Anyway, I didn't find a simple solution for that. My aim is is to calculate a net due date based on working days. So, If I've got a 30 days document days payment term  ("Deafult for baseline date" = Doc

  • [SOLVED]oracle.xdo.parser.v2.XMLParseException: Unexpected EOF

    hi frs, i have created a custom report using XML Publisher. i hve used two parameters in the report. one required and other optional. when i give both parameters report is working fine. but when i give only required it ends with an error. problem is

  • Sound Blaster Omni 5.1 Surround randomly loses audio in or out.

    When I'm playing games or voice chatting in skype - sometimes sound just go off or mic stops working. And I see that in Windows Playback devices sound bar is green as if sound is there, but nothing heard on headphones. I re-plug usb cable and it work

  • Baggage Files keep disappearing

    I am aware of the RH6 issue of the baggage files not being able to be added the traditional way, and the user having to add them manually in rhbag.apj file. I have done that and they do work after that is done, but my problem is that they keep disapp

  • SCOM: Service entered unpredictable state

    "The Orchestrator Run Program Service service is marked as an interactive service. However, the system is configured to not allow interactive services. This service may not function properly." We are seeing these alerts pop up in SCOM. It isn't a hug