Importing text file into database

Hi again,
Could anyone give me any pointers on how to take a text file or csv file (or any other delimeted text file) and read the contents into java and then use the read in data to then insert the delimeted data into the table.
i assume i have to read the delimeted data into a variable then parse the complete string with the delimeter and split the data up maybe in an array. Maybe this is completely wrong, im really unsure.
any help would be greatly appreciated even a point in the right direction would be great :)
kind regards.

Well, atleast i dont know of a single method, which does this kind of nonhomogenous task!! Its not hard to impliment what you want-->
//open the text file using FileInputStream & get the contents in a String variable
//Tokenise it
StringTokenizer st=new StringTokenizer(your_string_retrieved_from_file,delimiter);
int i=0;
while(st.hasMoreTokens())
i++;
//SQL Statement that inserts a string into database table(integer, varchar2)
insert into test_table values(i,st.nextToken());
Unless you are talking about putting the tokens as coloums in a single row, i dont find why this is a problem & if you are actually doing the above case, then you might wanna rethink your design

Similar Messages

  • Import a text file into database

    If anybody could help me with this, i would GREATLY appreciate it! I need to write a procedure to import a text file into an oracle database table. -Thanks!

    See my response in Re: import a text file into database.
    Cheers, APC

  • Import Text Files Into Apple Notes?

    Hello,
    Is there a way for me to automate importing text files into Apple Notes? I can certainly do this manually via copy/paste, but have over 700 files to transfer.
    Peace,
    Dr. Z.

    Automator is Apple's simple way to do tasks like this, but Notes app doesn't have any actions for this so I assume you need to use Applescript to do this. Double check Automator  - I am on 10.9 & maybe 10.10 added support for Notes in Automator? Enter 'Note' in the search field to see if Automator can make new Notes.
    There is an example for making notes at…
    http://www.macosxautomation.com/applescript/notes/04.html
    See the "Create New Stylized Note" script <- click script icon to download it, copy & paste seems to fail because of how the browser displays characters.
    You would need to adapt that script to import from the text files.
    I'm not sure you really want to do that anyway - Notes app has such poor support that putting serious data into it looks like a mistake - how difficult will it be to export data when Apple eventually abandon it? It seems like a toy app to me for new iPhone users, it;s unclear if it will ever be able to compete with other options. There are third party apps to export from Notes.app, but why rely on third parties? A notes app should allow you to import & export your data!
    Notational Velocity seems like a better choice…
    http://notational.net/
    It will handle notes as text files if you desire, so you can store them in Dropbox if you want. You can also set it to sync to Simplenote on iOS.
    http://simplenote.com/
    If you need images within notes or text styling you could use Evernote or one of the many other notes apps.
    Sorry to sound so negative on Notes.app, it's OK but I don't think its the best place to put over 700 notes.

  • Error importing text file into SQL Server when last column is null

    Hello all. Happy holidays!
    I'm trying to import a text file into a SQL Server table, and I get the error below when it gets to a row (row 264) that has null in the last column. I'm guessing the null jumbles up the delimiters somehow. The nulls are not errors, and I need to import
    them into the table with the rest of the rows. Any idea how I can do that?
    Thanks!
    [Flat File Source [1]] Error: Data conversion failed. The data conversion for column "XYZ" returned status value 2 and status text "The value could not be converted because of a potential loss of data.".
    [Flat File Source [1]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.  The "output column "XYZ" (178)" failed because error code 0xC0209084 occurred, and the error row disposition on "output column "XYZ"
    (178)" specifies failure on error. An error occurred on the specified object of the specified component.  There may be error messages posted before this with more information about the failure.
    [Flat File Source [1]] Error: An error occurred while processing file "ABC.txt" on data row 264.
    [SSIS.Pipeline] Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.  The PrimeOutput method on component "Flat File Source" (1) returned error code 0xC0202092.  The component returned a failure code when the pipeline engine called PrimeOutput().
    The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing.  There may be error messages posted before this with more information about the failure.
    WeeLass

    Hi WeeLass,
    The error that” Data conversion failed. The data conversion for column "XYZ" returned status value 2 and status text "The value could not be converted because of a potential loss of data.".” is generally error message, and the error indicates
    that there is data type mismatch issue between the input columns and the output columns.
    Based on your description, the issue is that you trying to convert a column contains empty value from string to integer data type for the output column "XYZ" in Flat File Source [1]. Please note that we cannot type an empty value as integer data
    type column value, so the error occurs.
    To fix this issue, just as you did, we should convert the data type for the output column "XYZ" in Flat File Source [1] back to DT_WSTR or DT_STR, then use a derived column task to replace the current column (UBPKE542). But the expression should
    be like below:
    LEN(TRIM(UBPKE542)) > 0 ? (DT_I8)UBPKE542 : NULL(DT_I8)
    In this way, the data type of the column in SQL table would be int, and the empty value would be replaced with NULL.
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Import text files into excel spreadsheet using automator

    Hello,
    I am trying to import a number of different text files into a single spreadsheet.  The content of each of the text files is the same (i.e. Same number of columns to be made) and each item is spac delimited.  I am trying to make it so that each of these text files will be entered into a single spreadsheet.  That is, one text file corresponds to one row of data and the second text file would correspond to the second row of data in the excel sheet.  Any ideas on how to do this?  I imagine this will require some sort of applescript but I'm not familiar with applescript at all!
    Thanks for your help!

    By the way, if anybody else has the same question I had:
    After trying this on my own, I recommend against doing what I did. I used the Excel macro language, Visual Basic for Applications. There are documented features in the Mac version that simply do nothing. I wasted a lot of time trying to find out why they wouldn't work. In other words, the online help told me they worked, but they didn't. I ended up with a combination of Automator and VBA and had to write my own code in VBA to duplicate the functionality that was supposed to be there.
    Also, it's my understanding that VBA on the Mac is a dead language and that Microsoft is concentrating on Excel's Applescript support, which appears to contain most (or all) of the functionality of VBA.
    I hope this helps someone else avoid making the same mistake I did!

  • Importing text file into search and redact window.

    I am in the search window under the search and redact tool.  I
    am trying to import a file that was originally an excel to populate the
    search multiple words window.  I read that text files can be imported.  I saved the file as a text file but it does not import.  I can import an adobe file but this gives me a list with a bunch of junk.  What am I missing?

    The dialog imports text files.
    Make sure that the file you are importing is a text file and has one word in every line.

  • Importing text file into 2D char array

    Hey folks. I've aged a few years trying to figure this project out. Im trying to make a crossword puzzle and am having problems importing the answer letters into a 2D array of 15*15. The text file would look something like this:
    LAPSE TAP RAH
    AVAIL OLE ODE
    BARGE PARADOX
    etc
    I have JTextFields that the user will answer and a button the user can press to see if the answers are right by comparing the 2D array answer with what the user inputted.-the user input would be scanned and put into a 2D array also.
    How should i go about inserting each letter into an array? The spaces i would later need to make code to grey out the text field. This is what i have so far. Forgive me if its sloppy.
         class gridPanel extends JPanel
              //----Setting Grid variables
              private static final int ROWS = 15;
              private static final int COLS = 15;
              String[] letters = { "A", "B", "C", "D", "E" };// To test entering strings into array
               gridPanel()
                 this.setBackground(Color.BLUE);
                 //.......Making my JTextField grid for user input
                 JTextField[][] grid = new JTextField[ROWS][COLS];
                 for(int ROWS = 0; ROWS<grid.length; ROWS++)
                     for(int COLS = 0; COLS<grid.length; COLS++)
                         grid[ROWS][COLS] = new JTextField(1);
                         add(grid[ROWS][COLS]);
                     //grid[ROWS][COLS].setText("" + letters[0]);
                 String an = null;
                 StringTokenizer tokenizer = null;
                 Character[][] answer = new Character[ROWS][COLS];
              try{
                 BufferedReader bufAns = new BufferedReader( new FileReader("C:\\xwordanswers.txt"));
                 for (int rowCurrent = 0; rowCurrent < ROWS; rowCurrent++)
              an = bufAns.readLine();
              tokenizer = new StringTokenizer(an);
              for (int colCurrent = 0; colCurrent < COLS; colCurrent++) {
              char currentValue = tokenizer.nextToken().charAt(0);//Needs to be changed to reflect each letter
                        answer[rowCurrent][colCurrent] = currentValue;
                    System.out.println(currentValue);
              }catch (IOException ioex)           
                        System.err.println(ioex);
                        System.exit(1);
            }//xword graphics end
          This obviously prints the first char of each word, it also gives me an "Exception in thread "main" java.util.NoSuchElementException" error for some reason.
    Any help is greatly appreciated.
    John

    If the file format is stored as follows:
    APPLE
    L A
    PARSE
    N E
    PEAR then we can parse this into a 2D char array:
    char[][] readMap(String fileName) {
        char[][] ret = new char[ROWS][COLS];
        FileInputStream FIS = new FIleInputStream(fileName);
        int i, j;
        for(i = 0; i < ROWS; i++)
            for(j = 0; j < COLS; j++)
                ret[i][j] = FIS.read();
        FIS.close();
        return ret;
    }Then you can use the resulting 2D char array in your answer checking mechanism.
    Hope this helps~
    Alex Lam S.L.

  • How to load data in plain-text file into database by using EJB?

    Hi,
    We need to develop an on-line application which requires us to load input data
    from a selected plain-text file on the Web server (iplanet server) into the backend
    oracle database. How could I use EJB to make it happen? it seems like using Entity
    EJB is not feasible.
    Really appreciate your help!
    Corona

    Hi Corona,
    "Corona Fang" <[email protected]> wrote in message
    news:3f3b0ea3$[email protected]..
    We need to develop an on-line application which requires us to load inputdata
    from a selected plain-text file on the Web server (iplanet server) intothe backend
    oracle database. How could I use EJB to make it happen? it seems likeusing Entity
    EJB is not feasible.If you are talking about loading thousands of records,
    the preferable way is using plain JDBC calls utilizing
    batch methods.
    Regards,
    Slava Imeshev

  • Importing Text Files  into Notes

    Having trouble reading imported text. I have IPod nano 3rd gen. It is checked to enable disc use. When I drop a .txt file into notes folder, then eject IPod, I can see the document titles in IPod/notes however, text displays as code (alot of 0's &1's and other garbled letters). Does anyone know why this happens and how I can solve this? I would greatly appreciate any suggestions.
    Thanks

    The files MUST be plain text files (possible sich text format as well) but not Word Documents and stuff like that. Simply taking a Word document and changing the extension from .doc to .txt won't do it for you, if that is what you tried.
    Patrick

  • Import text file into repository

    Hello,
    I have created the physical data model in Designer 10g.  I was given the table and column descriptions in an excel spreadsheet.
    Is there any way I can import these descriptions into the repository?
    Thanks
    Cathy

    Hi
    I actually can't answer your question because I'm having quite similar problems. But maybe you haven't created the correct table defs (index, and so on).
    By the way, how have you done to export the database to a txt-file. I can't do this and don't know why. Is it posible that you post your vi? this would be great.
    Do you have a good book or example about ActiveX and MSAccess? I can't find anything and the tutorials couldn't help me.
    Thanks and I hope my tip could help you.
    Yves

  • Importing text file into table

    hello
    i have a text file which contains data like empno,date and one character . every day this file is updated with new records.
    now i want this data to get inserted to a table, whenever new record has been appended to the text file
    can i have query or some way to do this. i can do it through sql loader, but i will not have info when the data is appended to the text file.
    pls help
    thanks in advance
    sdsreenivas

    If you're on 8.0.3 (which has been desupported for a number of years), then SQL*Loader strikes me as your best option. You could write a batch process that re-loads the file periodically so you see changes or you could write a batch file that polls the timestamp for the file and calls SQL*Loader whenever it is updated.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to import  text file to database 9i

    Hello friends. I need them to help me with problem.
    I have a file of separate text had called DEFA.TXT, located in the c:\, and I need to care him to the database.
    thank you
    Alexis Naranjo

    You probably want to use external tables for this. http://tahiti.oracle.com has all the Oracle documentation on-line-- a search there should get you plenty of information.
    Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com

  • Help needed in reading text file to database table

    Hello experts,
    i have to insert the values from the column of this text file and insert them in my database table.
    I have done a few file to table insertions but i'm having some trouble with this one.
    Any suggestions plz
    thanks
    liab_report      1.00                                                                                                                              Page: 1
    CDC:00537 / Mon Jun-21-2010                           LIABILITY REPORT                               Mon Jun-21-2010 22:06:26
    DRAW    1; SET    1;  November 7, 2009
                         TOTAL       PAID ON         TOTAL    EXPIRED ON         TOTAL    FRAC   OUTSTANDING
                       WINNERS      06/21/10          PAID      06/21/10       EXPIRED   ROUND
      DIVISION          AMOUNT        AMOUNT        AMOUNT        AMOUNT        AMOUNT  AMOUNT        AMOUNT
        Div1              0.00          0.00          0.00          0.00          0.00    0.00          0.00
        Div2         701040.00          0.00     660146.00          0.00      40894.00    0.00          0.00
        Div3        1444128.00          0.00    1330056.00          0.00     114072.00    0.00          0.00
        Div4        4711900.00          0.00    3889700.00          0.00     822200.00    0.00          0.00
                    6857068.00          0.00    5879902.00          0.00     977166.00    0.00          0.00
    DRAW    2; SET    1;  November 14, 2009
                         TOTAL       PAID ON         TOTAL    EXPIRED ON         TOTAL    FRAC   OUTSTANDING
                       WINNERS      06/21/10          PAID      06/21/10       EXPIRED   ROUND
      DIVISION          AMOUNT        AMOUNT        AMOUNT        AMOUNT        AMOUNT  AMOUNT        AMOUNT
        Div1              0.00          0.00          0.00          0.00          0.00    0.00          0.00
        Div2         817817.00          0.00     817817.00          0.00          0.00    0.00          0.00
        Div3        1687405.00          0.00    1611742.00          0.00      75663.00    0.00          0.00
        Div4        3402100.00          0.00    3034200.00          0.00     367900.00    0.00          0.00
                    5907322.00          0.00    5463759.00          0.00     443563.00    0.00          0.00
    DRAW    3; SET    1;  November 21, 2009
                         TOTAL       PAID ON         TOTAL    EXPIRED ON         TOTAL    FRAC   OUTSTANDING
                       WINNERS      06/21/10          PAID      06/21/10       EXPIRED   ROUND
      DIVISION          AMOUNT        AMOUNT        AMOUNT        AMOUNT        AMOUNT  AMOUNT        AMOUNT
        Div1              0.00          0.00          0.00          0.00          0.00    0.00          0.00
        Div2         779933.00          0.00     769804.00          0.00      10129.00    0.00          0.00
        Div3        1605548.00          0.00    1525104.00          0.00      80444.00    0.00          0.00
        Div4        4891700.00          0.00    4256800.00          0.00     634000.00    0.00        900.00
                    7277181.00          0.00    6551708.00          0.00     724573.00    0.00        900.00

    Plz clarify whether u want to load text file as a file into database or value of this text file into database. If values are to be loaded from this text file, U can better format the text file and use SQL loader to load the file into database. By formatting the database, i mean remove the unnecessary headings and characters, kee only the values to be loaded idelimited by ' '(space) or ','(comma). Create a control file and load it into the target table.

  • USING WEBUTIL TO READ TEXT FILE INTO TABLE HANGS AFTER CERTAIN NUMBER OF RE

    Dear
    when we use webutil to retrieve data from text file into database table
    (using text_io) it hangs after certain number of records ( approx. 1300
    records) while the total number of records to be inserted in the table exceeds
    12000 records while it works properly on forms6i with the normal text_io any
    help please...?
    thanks and regards

    WebUtil uploads the files as Binary - so yes you could have some issues if you have a Unix host - however, that would only mean that there is an extra character to trim off of the end of the line read by Text_io.

  • Import txt file into user dictionary

    How to import text file into user dictionary through javascript? I can manually import txt file into user dictionary thru "Edit=>Spelling=>User dictionary...". But I don't know how to do it using javascript. Please advise.

    Advice? See in some version of the object-model reference under userDictionary. There you'll find a method called addWord(), which looks promising.
    Peter

Maybe you are looking for

  • Make a item flexfield mandatory at running time

    Hi everybody, I am going to ask something that maybe is not very normal, but, my client really want it. I have a descriptive flexfield with several itmes. We want to make one ot these items mandatory at running time based on one condition but in the

  • Windows PC can only print one copy at a time

    I've got a PC connected to a Mac printer via Bonjour. It works fine, except for this new quirk we discovered today... when attempting to print 30 copies of a PDF, only 1 copy would print. Any suggestions (other than hitting Print 30 times in a row)?

  • Runtime error in include L0COEF05

    Hi, When executing a standard program.there is a runtime call to a form Call_by_cluster_only present in standard include L0COEF05 present in function group SAPL0COE .This is onlt creating issue in ECC6.0 however it is working fine in 4.6C. In ECC6.0

  • Authorization problem with VF01 "Create Billing Documents"

    Dear All, We face following problem with VF01 "Create Billing Documents". Transaction: VF01 User: Joe Authorization of Joe:      VKORG Sales Organization: A, B (authorization object V_VBRK_VKO)      FKART Billing Type: 1, 2 (authorization object V_VB

  • Have just purchased Lion and unable to get to store to download.  Using iMac  OS10.6.8

    Have just purchased Lion, have Redemption code, etc, but unable to get to place to download.  Using OS 10.6.8