CSV & Java

Hello,
I have some question....I must make school schedule as a web service...School schedule is in csv file, i need parse it and search and return some results. Which class is best to save data from CSV? I used ArrayList bud I think that is no effective...:-(
Can someone help me resolve this question?
Thanks a lot....

GrEEn_SK wrote:
I have something like this:
Day; Time; Subject; Proffesor; Faculty; Duration
Fr; 10:00-12:00; Programming in Java; Faculty of Mechatronics; 2
And I need to parse this data, and be able to search and return search results....How much data are we talking about? How are you now storing it in your ArrayList, as Strings or did you create custom classes?

Similar Messages

  • Java CSV

    Hi, I'm writing a program in java that has to upload a csv file from the disk, but i can´t find examples to guide me, (I´m new in Java HTMLB programing).
    Can anybody help me ...

    Hi Virginia,
    ok for the first step, you might have a look at: http://ostermiller.org/utils/ExcelCSV.html
    There is a Java parser for the special Excel CSV format (which doesn't conform to "standard" CSV rules).
    Having the resolved data in the corresponding String array(s) it should be easy to format it as a Html table.
    There are many other resources out there in the WWW, you could search for "reading CSV java" using Google for example.
    Is it mandatory for you to use HTMLB? What about creating a Web Dynpro application for that?
    Hope that helps.
    Regards
    Stefan

  • Fault handling in FTP adapter

    Hi Gurus,
    I have configured Rejection message handler to send the rejected file into a location of an FTP server. The action part of my fault policy looks like this
    <Actions>
    <Action id="writeToFile">
    <fileAction>
    <location>/u03/sftpuser/out</location>
    <fileName>stud.csv</fileName>
    </fileAction>
    </Action>
    But it is not writing the file here. The error in the logs shows as below
    [2013-11-06T02:00:21.145-05:00] [soa_server1] [WARNING] [] [oracle.integration.platform.faulthandling.recovery] [tid: Workmanager: , Version: 0, Scheduled=false, Started=false, Wait time: 0 ms\n] [userId: weblogic] [ecid: 5644e604b69ae2c7:6287cedb:14143ebdfe9:-8000-0000000000683616,0] [APP: soa-infra] Not able to write metadata to file: /u03/sftpuser/out/stud_metadata.csv[[
    java.io.FileNotFoundException: /u03/sftpuser/out/stud_metadata.csv (Permission denied)
    [2013-11-06T02:00:21.146-05:00] [soa_server1] [WARNING] [] [oracle.integration.platform.faulthandling] [tid: Workmanager: , Version: 0, Scheduled=false, Started=false, Wait time: 0 ms\n] [userId: weblogic] [ecid: 5644e604b69ae2c7:6287cedb:14143ebdfe9:-8000-0000000000683616,0] [APP: soa-infra]  [RejectedMsgHandling]Unable to apply policies on the rejected message with id - 10[[
    java.io.FileNotFoundException: /u03/sftpuser/out/stud_metadata.csv (Permission denied)
    I have checked the FTP server and at this location all the permissions are granted. Please let me know what i am missing here.
    Thanks
    Ayush

    Are you able to ftp to the same location via putty ? Also, you could increase the log level from the EM Console to level 32 for granular log details.

  • AdvancedDataGrid with XMLListCollection Syntax

    Hello All,
    I'm more of an XSLT/XPath guy, and need help with the syntax
    for Flex(if that's the only thing I'm doing wrong!). I have an
    XMLListCollection named "mapData" with records from a web service.
    Each record looks like this:
    <java:Results xmlns:java="java:com.example.com">
    <java:AssociatedFileID>9999</java:AssociatedFileID>
    <java:AssociatedFileName>example.csv</java:AssociatedFileName>
    <java:DataBucketID>123</java:DataBucketID>
    <java:DataBucketName>EDashboard</java:DataBucketName>
    <java:Fields>
    <java:DataBucketFieldName>Business</java:DataBucketFieldName>
    <java:DataBucketFieldValue>Loans</java:DataBucketFieldValue>
    <java:DataBucketFieldID>4281</java:DataBucketFieldID>
    </java:Fields>
    <java:Fields>
    <java:DataBucketFieldName>Section</java:DataBucketFieldName>
    <java:DataBucketFieldValue>Europe</java:DataBucketFieldValue>
    <java:DataBucketFieldID>4394</java:DataBucketFieldID>
    </java:Fields>
    <java:LoadedDateTime>2008-03-19T10:57:21-04:00</java:LoadedDateTime>
    <java:Suppressed>No</java:Suppressed>
    <java:DataBucketContentID>170</java:DataBucketContentID>
    <java:Status>Active</java:Status>
    </java:Results>
    My AdvancedDataGrid is:
    <mx:AdvancedDataGrid x="10" y="10" id="MapDG"
    designViewDataType="flat" width="100%" height="100%"
    dataProvider="{mapData}" click="{editBtn.enabled=true;}"
    selectionMode="singleRow" change="{editBtn.enabled=true;}">
    <mx:columns>
    <mx:AdvancedDataGridColumn headerText="ID"
    dataField=""/>
    <mx:AdvancedDataGridColumn headerText="Business"
    dataField=""/>
    <mx:AdvancedDataGridColumn headerText="Section"
    dataField=""/>
    </mx:columns>
    </mx:AdvancedDataGrid>
    Here's what I'm trying to do for each column:
    1 - *::Results.*::DataBucketContentID.text()
    //this is the record ID
    2. -
    *Results.*::Fields.(*::DataBucketFieldName.text()='Business').*DataBucketFieldValue.text( )
    //Gets the 'DataBucketFieldValue' for each 'Fields' that has
    a 'DataBucketFieldName' = Business
    3. -
    *Results.*::Fields.(*::DataBucketFieldName.text()='Section').*DataBucketFieldValue.text()
    //Gets the 'DataBucketFieldValue' for each 'Fields' that has
    a 'DataBucketFieldName' = Section
    What do I need to put in the columns' dataField for this to
    work?
    Thanks,
    Trav

    Thanks to Tracy and a little research, I have my data grid
    populating - I wanted to post an example that worked for me:
    If below is a variable with your web service result...
    private var personXML:XML=<persons>
    <person>
    <FirstName>Santa</FirstName>
    <Surname>Claus</Surname>
    <Age>1000</Age>
    </person>
    <person>
    <FirstName>Tooth</FirstName>
    <Surname>Fairy</Surname>
    <Age>250</Age>
    </person>
    <person>
    <FirstName>Travis</FirstName>
    <Surname>Allen</Surname>
    <Age>27</Age>
    </person>
    </persons>
    You can use a function, which you'll need to assign to a
    column. Here it is concating text in 2 elements but you can also
    use it for namespaced elements (e.g.
    item.*::NodeName1.*::NodeName2.text()).
    private function showFullName(item:Object,
    Column:DataGridColumn):String{
    var fullName:String = item.FirstName + " " + item.Surname;
    return fullName;
    The first column uses the function to populate the data in
    the column. It has to use labelFunction (vs. dataField). The 2nd
    uses the node name directly.
    <mx:DataGrid id="personDG"
    dataprovider="{personXML.person}">
    <mx:columns>
    <mx:DataGridColumn width="150" headerText="Full Name"
    labelFunction="showFullName"/>
    <mx:DataGridColumn width="150" dataField="Age"
    width="50"/>
    <!--the column without header text wil take the value of
    the element-->
    </mx:columns>
    </mx:DataGrid>
    Hope this helps anyone else!
    Trav

  • ODISQLUnload Issue....

    Hi Experts,
    I have a requirement to export all the data from a Oracle table to file, i tried odi tool ODISQLUnload and its exporting the data as expecxted but i am not getting the columnn name as such.
    Can anyone help me in this, its driving me crazy for two days.
    regrds,
    K

    Yes, i can now able to select the KM, but when i executed its failed with
    7000 : null : java.sql.SQLException: File not found: ../demo/file/my_file.csv
    java.sql.SQLException: File not found: ../demo/file/my_file.csv
         at com.sunopsis.jdbc.driver.file.x.<init>(x.java)
         at com.sunopsis.jdbc.driver.file.a.d.d.a(d.java)
         at com.sunopsis.jdbc.driver.file.g.a(g.java)
         at com.sunopsis.jdbc.driver.file.w.executeQuery(w.java)
         at com.sunopsis.sql.SnpsQuery.executeQuery(SnpsQuery.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.getTargetOrderMetaData(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execCollOrders(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSqlI.treatTaskTrt(SnpSessTaskSqlI.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
         at com.sunopsis.dwg.cmd.e.i(e.java)
         at com.sunopsis.dwg.cmd.g.y(g.java)
         at com.sunopsis.dwg.cmd.e.run(e.java)
         at java.lang.Thread.run(Unknown Source)
    please help me....

  • Crystal report - generate CSV file through Java interface

    Hi,
    I need to generate a Character Seperated File through Crystal Report 10 using Java.
    What constant stands for CSV Format and what value of SI_PROGID we can provide to pull the CSV format.
    Eg. SI_PROGID = ceProgID.EXCEL or SI_PROGID = ceProgID.PDF .....
    Currentlly we are crystalLibs.jar to connect the Crystal server.
    Thanks In Advance

    In BusinessObjects Enterprise installations, the following ProgIDs are valid.
    CrystalEnterprise.Analytic
    CrystalEnterprise.AppFoundation
    CrystalEnterprise.Calendar
    CrystalEnterprise.Category
    CrystalEnterprise.Connection
    CrystalEnterprise.Designer
    CrystalEnterprise.Destination
    CrystalEnterprise.DiskUnmanaged
    CrystalEnterprise.Event
    CrystalEnterprise.Excel
    CrystalEnterprise.Folder
    CrystalEnterprise.FavoritesFolder
    CrystalEnterprise.Ftp
    CrystalEnterprise.Hyperlink
    CrystalEnterprise.Inbox
    CrystalEnterprise.InfoView
    CrystalEnterprise.LicenseKey
    CrystalEnterprise.Managed
    CrystalEnterprise.MyInfoView
    CrystalEnterprise.ObjectPackage
    CrystalEnterprise.Overload
    CrystalEnterprise.Pdf
    CrystalEnterprise.PersonalCategory
    CrystalEnterprise.Powerpoint
    CrystalEnterprise.Program
    CrystalEnterprise.Report
    CrystalEnterprise.Rtf
    secEnterprise
    secLDAP
    CrystalEnterprise.Server
    CrystalEnterprise.ServerGroup
    CrystalEnterprise.Shortcut
    CrystalEnterprise.Smtp
    CrystalEnterprise.Txt
    CrystalEnterprise.Universe
    CrystalEnterprise.User
    CrystalEnterprise.UserGroup
    CrystalEnterprise.Webi
    CrystalEnterprise.Word

  • How can I export the universe  to CSV format in Rational      (java)

    How can I export the universe to CSV format in Rational ,please give me one demo .thanks!!

    There's no direct access to an Universe from Java - Universes do have an SDK, but it's COM-based.
    If what you want is to retrieve data from the Universe, what you can do is create a Web Intelligence document reporting off that Universe, create a Query with the data you want from the Universe, then use the ReportEngine (REBean) SDK to retrieve the ResultSet from the Query - note that there's no CSV export option, so you'd have to walk through the ResultSet and write to an CSV yourself.
    Sincerely,
    Ted Ueda

  • Generating CSV file with column names and data from the MySQL with JAVA

    Hi all,
    Give small example on ...
    How can I add column names and data to a CSV from from MySQL.
    like
    example
    sequence_no, time_date, col_name, col_name
    123, 27-apr-2004, data, data
    234, 27-apr-2004, data, data
    Pls give small exeample on this.
    Thanks & Regards
    Rama Krishna

    Hello Rama Krishna,
    Check this code:
    Example below exports data from MySQL Select query to CSV file.
    testtable structure
    CREATE TABLE testtable
    (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    text varchar(45) NOT NULL,
    price integer not null);
    Application takes path of output file as an argument.
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.Statement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    public class automateExport {
        public static void main(String[] args) {
            DBase db = new DBase();
            Connection conn = db.connect(
                    "jdbc:mysql://localhost:3306/test","root","caspian");
            if (args.length != 1) {
                System.out.println(
                        "Usage: java automateExport [outputfile path] ");
                return;
            db.exportData(conn,args[0]);
    class DBase {
        public DBase() {
        public Connection connect(String db_connect_str,
                String db_userid, String db_password) {
            Connection conn;
            try {
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                conn = DriverManager.getConnection(db_connect_str,
                        db_userid, db_password);
            } catch(Exception e) {
                e.printStackTrace();
                conn = null;
            return conn;
        public void exportData(Connection conn,String filename) {
            Statement stmt;
            String query;
            try {
                stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                        ResultSet.CONCUR_UPDATABLE);
                //For comma separated file
                query = "SELECT id,text,price into OUTFILE  '"+filename+
                        "' FIELDS TERMINATED BY ',' FROM testtable t";
                stmt.executeQuery(query);
            } catch(Exception e) {
                e.printStackTrace();
                stmt = null;
    Greetings,
    Praveen Gudapati

  • Error: java.lang.OutOfMemoryError when uploading CSV files to web server

    Hi experts,
    I have made a JSP page from which clients load csv files to web server. I am using Tomca 4.1 as my web server and JDK 1.3.1_09.
    The system works fine when uploadiing small csv files, but it crashes when uploading large CSV files.
    It gives me the following error:
    java.lang.OutOfMemoryError
         <<no stack trace available>>
    This is the code that I used to load files....
    <%
    String saveFile = "";
    String contentType = request.getContentType();
    if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0))
         DataInputStream in = new DataInputStream(request.getInputStream());
         int formDataLength = request.getContentLength();
         byte dataBytes[] = new byte[formDataLength];
         int byteRead = 0;
         int totalBytesRead = 0;
         while (totalBytesRead < formDataLength)
              byteRead = in.read(dataBytes, totalBytesRead, formDataLength);
              totalBytesRead += byteRead;
         String file = new String(dataBytes);
         saveFile = file.substring(file.indexOf("filename=\"") + 10);
         saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
         saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1,saveFile.indexOf("\""));
         int lastIndex = contentType.lastIndexOf("=");
         String boundary = contentType.substring(lastIndex + 1,contentType.length());
         int pos;
         pos = file.indexOf("filename=\"");
         pos = file.indexOf("\n", pos) + 1;
         pos = file.indexOf("\n", pos) + 1;
         pos = file.indexOf("\n", pos) + 1;
         int boundaryLocation = file.indexOf(boundary, pos) - 4;
         int startPos = ((file.substring(0, pos)).getBytes()).length;
         int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
         String folder = "f:/Program Files/Apache Group/Tomcat 4.1/webapps/broadcast/file/";
         //String folder = "10.28.12.58/bulksms/";
         FileOutputStream fileOut = new FileOutputStream(folder + saveFile);
         //out.print("Saved here: " + saveFile);
         //fileOut.write(dataBytes);
         fileOut.write(dataBytes, startPos, (endPos - startPos));
         fileOut.flush();
         fileOut.close();
         out.println("File loaded successfully");
    //f:/Program Files/Apache Group/Tomcat 4.1/webapps/sms/file/
    %>
    Please can anyone help me solve this problem for me...
    Thanx...
    Deepak

    I know it may be hard to throw away all this code, but consider using the jakarta fileupload component.
    I think it would simplify your code down to
    // Create a factory for disk-based file items
    FileItemFactory factory = new DiskFileItemFactory();
    // Create a new file upload handler
    ServletFileUpload upload = new ServletFileUpload(factory);
    // Parse the request
    List /* FileItem */ items = upload.parseRequest(request);
    // Process the uploaded items
    Iterator iter = items.iterator();
    while (iter.hasNext()) {
        FileItem item = (FileItem) iter.next();
        if (item.isFormField()) {
            processFormField(item);
        } else {
            // item is a file.  write it
            File saveFolder = application.getRealPath("/file");          
            File uploadedFile = new File(saveFolder, item.getName());
            item.write(uploadedFile);
    }Most of this code was hijacked from http://jakarta.apache.org/commons/fileupload/using.html
    Check it out. It will solve your memory problem by writing the file to disk temporarily if necessary.
    Cheers,
    evnafets

  • How to export report IN CSV format through JAVA.

    how to export report in csv format.when try to export in csv format.its exporting into csv but report not containing column heading , report heading and it showing all the data in a single line.we have integrated the reports with java.

    Use a Java API which can create PDF files based on some collection of plain vanilla Java objects (List, String, Number, etc).
    Google can find them all. Just feed it with something like "Java PDF API" or so. A commonly used one is iText.
    That said, when talking about this in JSP context, ensure that you do NOT write raw Java code in JSP files using scriptlets. Raw Java code belongs in Java classes. In such case you need a Servlet. In JSP just use taglibs and EL to interact with backend Java code and data. Scriptlets are discouraged since over a decade.

  • UTF-8 csv file generated by Java can't be displayed correctly on Excel 2000

    Hi, I have a question about the file geneated by Java in UTF-8 format. If I have a file named "foo.csv" generated by my java code like this:
    writer = new OutputStreamWriter(new FileOutputStream("foo.csv"), "UTF-8");
    Then I write some data loaded from a MS SQL 2000 server to this file. Some data are in German or french characters. After the file is generated, if I open it in notepad, all the characters in the file looks good. The file is in UTF-8 format. The only problem is that when I open this csv file in MS Excel 2000, all the non-english character display incorrectly. For example:
    "VERKTYGSTEKNIK I V�XJ� AB" display as itself in notepad, but it display as "VERKTYGSTEKNIK I V��XJ�� AB" in the MS Excel. I don't know the reason. If I don't have the encoding in the writer, then the file generated looks fine in the Excel (Even the non-English characters), in this case, the file is generated in ANSI format. But my client wants the file in UTF-8 format and also want to view it in Excel.
    Why the UTF-8 file generated by Java can't be displayed correctly in Excel 2000?
    My environment is:
    OS: Window 2000 Server English Version
    JDK: Sun jdk1.3.1
    Thanks

    - Does ms excell actually support UTF-8
    Yes. I believed that we installed some international add-on which is not in default installnation. Anyway, other UTF-8 or UTF-16 file can be openned and viewed by Excel without any problem.
    - have you verifide that the file is viewable as a UTF-8 -encoded file
    I think so. If I open it into Notepad and choose "save as", the file type if UTF-8 file
    - Try opening the file in a program you are confident
    that it support UTF-8 - eg. Mozilla...
    I will try that.
    - Check that your UTF-8 -encoded file has a UTF-8 identifier (0xFEFF ?)
    as the first character
    The unicode-16(LE or BE) file I got from internet, I found there is always two bytes in the front. (0xFEFF or 0xFFFE). My UTF-8 file generated by java doesn't have that. But should UTF-8 file also has this kind of specifcal bytes in the front? If I manually add these bytes in the front of my file using Ultraeditor and open it in Excel2000, it didn't help.
    - Try using another spreadsheet program that supports UTF-8
    Do you know any other spreadsheet program supports csv file and UTF-8.

  • Accessing a .csv file in vi while the data is written by 3rd party java applicaito​n

    Hi
    I have a requirement like below explained.
    A java applicaiton reads data from hardware and writes in a .csv file. This java applicaiton is triggered by a button click in Labview VI.
        --> cmd window   -- cmd /C java Client n
    the data will be read from hardware and written to the file per every second.
    In the labview vi, we are reading the .csv file simultaneously and plotting the graph. 
    The above operations need to happen simultaneously. 
    When we tried this, we are geeting the "File Not Found Excpetion(the file is used by other process) in java application.
    Can anyone help me why this might be happening in Labview. I tried this with a "c" applicaiton instead of Labview and it is working fine.
    Problem observed only with labivew.
    Regards
    Kris

    Naah, I said, that will never work.  But to my shock and (pleasant) surprise, it does!  Here is a snippet of a little routine I cobbled together using LabVIEW for both the Writer and the Reader.
    The Writer is on top.  It creates a Temp.txt file on my Temp directory, deletes it if it is already there, then opens it for writing.  There's a boolean "Done" flag that tells me when the Writer finishes, so I clear it before entering the Writing Loop.  Here, every half-second, I write the sequential numbers 0 .. 9, with a New Line to create a Text File of Lines.  When I'm finished, I close the file.
    Below this is the Reader Loop, designed to start after the Writer Loop has opened (and created) the file.  Here we open the same file in Read-Only mode.  The Reader Loop also goes 10 times (I could have built in a Stop condition, but this is only a Proof-of-Concept).  The loop is initialized with the current File Position (0) in a Shift Register.  The inner While Loop is a "Wait for Data to Appear", a loop which checks 10 times a second to see if the File Position has changed, exiting when it does (meaning the Writer has Written Something).  It then reads a line from the File (the Read Text function has its "Read Lines" property set) and displays it.
    When you run this, you will see the Reader's output, Line, count up, 0 .. 9, and then the program stops with no errors.  What fun!
    Bob Schor

  • Import CSV/Excel data into Flex Datagrid using Java/JSP

    Hi,
    Is there any way we can import excel/csv data into flex datagrid component.
    I see that is been done using php in this site. http://code.google.com/p/as3xls/
    Any help would be appreciated.
    Thanks in advance

    You can store the list of data from the Excel sheet that you have read already into an ArrayList
    Then go through the JDBC tutorial, and learn how to insert a single record into the table.
    After you understand how to insert a single record, you can iterate through the ArrayList of data and insert them into the table in the database.
    If you know JDBC, see if you can use OR Mapping frameworks like Hibernate or iBatis, they make it very easy to manage database in Java.

  • Using Java Servlet with CSV

    Hello!!
    I would be obliged if some one could tell me anyway of using CSV (Collaborative Source Versioning) with Java Servlets. I have searched and the only package that I have found is jCSVSlet but I can't figure out how to use it. I would be obliged if anybody could point out any other packages that can be used for File Versioning or if anybody could send me any examples of JCSVSlet or any other related software.
    Saad Tawwab

    And what do you mean by "with"? Do you want to control versions of the source code of the servlets, or do you want to write a servlet to control version of the source code of something else?

  • Need JAVA code to create OIM ITresource-connection values are in a csv file

    Hi,
    Could any one plz help me with the java code used / tested before to create OIM IT resource dynamically, for the reference. IT resource parameter (connection) values in a .csv file, where in I've multiple environments.
    Thanks,
    Ramesh
    Edited by: user13267745 on Aug 19, 2010 12:37 AM

    Hi Gregg,
    You can create one transformation from the DataStore to itself.  In the "Technical" rules group, set 0RECORDMODE = 'X' (before image) or 'R' (reverse).  Therefore, when you execute its corresponding DTP, all existing records shouldl be set to zero.
    Then, as a second step, you can execute the DTP which is related to the transformation between the DataStore and the DataSource, thus loading the new records.
    I hope this helps you.
    Regards,
    Maximiliano

Maybe you are looking for