Load / Update Table from a .csv file

Hi All,
I thought I would just throw this out there..be kind.
I have a requirement to build a page that allows the user to upload a excel (well I'll have them save it as a .csv) and upate an existing table in their schema.
I have successfully created a similar page for inserting into an existing table however my update is not working. Then I realized what the Oracle Application Express Tool does that for me on, LOAD DATA page. The feature I like best is that after browsing for the file and clicking next it shows the column header and the row data underneath. I would really like to duplicate the functionality of this page.
I looked into the flows schema found related procedures , for example wwv_flow_load_excel_data,but I'm lost on how to use them.
Is there a way to duplicate the LOAD DATA Page and fit it to meet the users requirement?
Also I have included my coding attempt :
CREATE OR REPLACE PROCEDURE exceltotable2
AS
NAME: exceltotable
PURPOSE:
REVISIONS:
Ver Date Author Description
1.0 11/17/2008 1. Created this procedure.
NOTES:
Automatically available Auto Replace Keywords:
Object Name: exceltotable
Sysdate: 11/17/2008
Date and Time: 11/17/2008, 2:02:03 PM, and 11/17/2008 2:02:03 PM
Username: (set in TOAD Options, Procedure Editor)
Table Name: (set in the "New PL/SQL Object" dialog)
v_blob_data BLOB;
v_blob_len NUMBER;
v_position NUMBER;
v_raw_chunk RAW (10000);
v_char CHAR (1);
c_chunk_len NUMBER := 1;
v_line VARCHAR2 (32767) := NULL;
v_data_array APEX_APPLICATION_GLOBAL.VC_ARR2;
v_rows NUMBER;
v_asset_id NUMBER;
v_new_location GINOS_LOCATION.ID_LOCATION%TYPE ;
sql_stmt VARCHAR2 (2000);
--delete from data_upld;
BEGIN
-- Read data from wwv_flow_files</span>
SELECT blob_content
INTO v_blob_data
FROM wwv_flow_file_objects$
     WHERE NAME = 'F32700/scannedforrdc.csv';
     --(used this for testing)
-- WHERE last_updated = (select max(last_updated) from WWV_FLOW_FILE_OBJECTS$ where UPDATED_BY
-- = 'ADMIN')
--and id = (select max(id) from WWV_FLOW_FILE_OBJECTS$ where UPDATED_BY = 'ADMIN');
v_blob_len := DBMS_LOB.getlength (v_blob_data);
v_position := 1;
-- Read and convert binary to char</span>
WHILE (v_position <= v_blob_len)
LOOP
v_raw_chunk := DBMS_LOB.SUBSTR (v_blob_data, c_chunk_len, v_position);
v_char := CHR (hex_to_decimal(RAWTOHEX(v_raw_chunk)));
v_line := v_line || v_char;
v_position := v_position + c_chunk_len;
-- When a whole line is retrieved </span>
IF v_char = CHR (10)
THEN
-- Convert comma to : to use wwv_flow_utilities </span>
v_line := REPLACE (v_line, ',', ':');
-- Convert each column separated by : into array of data </span>
v_data_array := APEX_UTIL.string_to_table (v_line);
-- Update assets with RDC location
-- First get the current location id of the RDC
-- Next take each serial number from the spreadsheet and update the location and rack details </span>
Select id_location into v_new_location from ginos_location gl, ginos_site gs, ginos_agency ga
where nm_office = 'OCFS Resource Distribution Center' and gl.id_site = gs.id_site
And gl.id_agency = ga.id_agency And ga.nm_agency ='Office of Children and Family Services';
-- test with only the serial number/location
UPDATE GINOS_ASSET SET ID_LOCATION = v_new_location WHERE NM_SERIAL = v_data_array(1);
-- Clear out
v_line := NULL;
v_rows := v_rows + 1;
END IF;
END LOOP;
END;
Any advice/assistance is always appreciated
Thanks
Moe

Dan
Thank You for your reply, I actually bookmark your site yesterday when googling this problem.
I am going to give it a try. I have ran through steps 1 through 4. Step 4 , I modified to my page.
Just a little more help..
do I put my update table code in the procedure (step 4) - how do I view and extract the information from the collection?
DECLARE
l_blob BLOB;
PROCEDURE cleanup
IS
BEGIN
DELETE FROM WWV_FLOW_FILES
WHERE name = :P103_UPLOAD;
END cleanup;
BEGIN
SELECT blob_content
INTO l_blob
FROM WWV_FLOW_FILES
WHERE name = :P103_UPLOAD;
csv.create_collection_from_blob(l_blob, 'CSV_UPLOAD', 'Y');
-- I looked in the ginodba schema (the ref schema for the app) for this collection but it's not there
cleanup;
EXCEPTION
WHEN OTHERS
THEN
cleanup;
RAISE;
END;
Thanks Again
MOe

Similar Messages

  • Loading a CLOB from a CSV file into Oracle

    I'm consuming data files from a third party and I need to load them into an Oracle database. One of the files has a field that's described in the data dictionary as varchar2(8000) which will obviously need to be stored as a CLOB.
    I have two questions:
    1. How do I create a Model for the data file when CLOB isn't available as the Type of a column.
    2. Will I need to do anything fancy to get it into a CLOB column in an Oracle table? I'm using "LKM File to Oracle (SQLLDR)" and "IKM Oracle Incremental Update (PL SQL)"

    I ended up running the file through a Java app to trim the field down to 4000 characters.
    I can't believe an Oracle product can't handle an Oracle data type - very poor.

  • Loading a table from multiple input files using sqlldr

    Hi,
    For my project i need to load into a table by joining two input files using sqlldr. For example,
    I have a file1, which has values
    name,salary,ssn
    and file2 which has values for
    ssn,location,country
    now i need to load these values into a table say employee_information by joining both input files. both input files can be joined using ssn as common field.
    Any idea how to do this??
    Thanks in advance
    Satya.

    Hi,
    What is the size of the files. If possible mail me the sample files, And the structure of table. Is the <ssn> from first file and second will have seperate columns in the table or we have to merge it.
    SKM

  • Loading multiple tables from one xml-file

    I've got one xml-file containing information which should be loaded into multiple database tables. How can I do that?

    Please use XSLT to tranform to XML file with XSU recognized format and separated for different table input.
    You may refer to Example in book "Building Oracle XML Applications".
    null

  • SQL*Loader - How to load only a few columns from a .csv file to ora table

    Hi there,
    Could anyone please let me know how to load few columns from a .csv
    file into a oracle table using SQL*Loader.
    I know how to create a .dat and .ctl file and run the sql loader.
    Suppose I have a .csv file with
    col1, col2, col3, col4
    and I only need to load col1 and col3 into col_a and col_b respectively
    in table_a?
    structure of table_ a
    col_a,
    col_b
    Please advice

    Try like..it i will work..
    LOAD DATA
    INFILE 'test.txt'
    LOAD DATA
    TRUNCATE INTO TABLE T1
    FIELDS TERMINATED BY ','
    (col1,
    col2 FILLER,
    col3,
    col4 FILLER
    )

  • Need help in loading data from a csv file to a table in Oracle DB

    Hi,
    I am using sqlplus as a client to connect to the server.
    I am trying to load data from a csv file from a client to a table in Oracle DB server.
    I am trying to use the below command
    " LOAD DATA INFILE 'test.csv' INTO TABLE testTable FIELDS TERMINATED BY ',' (test1,test2,testc3,testc4); "
    But, I am encountered with the following error
    "SP2-0042: unknown command "load data" - rest of line ignored."
    Thanks in advance.
    SB

    Hey Frostmann,
    That was a nice post....
    I changed my mind to use an 'Insert into' statement from a shell script.
    I created a DB table named test and I tried using the below shell script to insert a row in the table.
    sqlplus test/test@test <<ENDOFSQL
    INSERT INTO test VALUES('test1',123,'test2','test3');
    exit
    ENDOFSQL
    A row is succesfully inserted into the table when I run the script manually, but it does not insert rows when a cron job is scheduled.
    Could you please help me with this?
    Thanks in advance.
    SB

  • ODI Error when Loading data from a .csv file to Planning

    Hello,
    I am trying to load data from a csv file to planning using ODI 10.1.3.6 and I am facing this particular error. I am using staging area as Sunopsis memory engine.
    7000 : null : java.sql.SQLException: Invalid COL ALIAS "DEFAULT C12_ALIAS__DEFAULT" for column "ALIAS:"
    java.sql.SQLException: Invalid COL ALIAS "DEFAULT C12_ALIAS__DEFAULT" for column "ALIAS:"
         at com.sunopsis.jdbc.driver.file.bb.b(bb.java)
         at com.sunopsis.jdbc.driver.file.bb.a(bb.java)
         at com.sunopsis.jdbc.driver.file.w.b(w.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.execCollOrders(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt(SnpSessTaskSqlC.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.k(e.java)
         at com.sunopsis.dwg.cmd.g.A(g.java)
         at com.sunopsis.dwg.cmd.e.run(e.java)
         at java.lang.Thread.run(Unknown Source)
    Code from Operator:
    select     Account     C1_ACCOUNT,
         Parent     C2_PARENT,
         Alias: Default     C12_ALIAS__DEFAULT,
         Data Storage     C3_DATA_STORAGE,
         Two Pass Calculation     C9_TWO_PASS_CALCULATION,
         Account Type     C6_ACCOUNT_TYPE,
         Time Balance     C14_TIME_BALANCE,
         Data Type     C5_DATA_TYPE,
         Variance Reporting     C10_VARIANCE_REPORTING,
         Source Plan Type     C13_SOURCE_PLAN_TYPE,
         Plan Type (FinStmt)     C7_PLAN_TYPE__FINSTMT_,
         Aggregation (FinStmt)     C8_AGGREGATION__FINSTMT_,
         Plan Type (WFP)     C15_PLAN_TYPE__WFP_,
         Aggregation (WFP)     C4_AGGREGATION__WFP_,
         Formula     C11_FORMULA
    from      TABLE
    /*$$SNPS_START_KEYSNP$CRDWG_TABLESNP$CRTABLE_NAME=Account.csvSNP$CRLOAD_FILE=Y:/1 Metadata/Account//Account.csvSNP$CRFILE_FORMAT=DSNP$CRFILE_SEP_FIELD=2CSNP$CRFILE_SEP_LINE=0D0ASNP$CRFILE_FIRST_ROW=1SNP$CRFILE_ENC_FIELD=SNP$CRFILE_DEC_SEP=SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=AccountSNP$CRTYPE_NAME=STRINGSNP$CRORDER=1SNP$CRLENGTH=150SNP$CRPRECISION=150SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=ParentSNP$CRTYPE_NAME=STRINGSNP$CRORDER=2SNP$CRLENGTH=150SNP$CRPRECISION=150SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=Alias: DefaultSNP$CRTYPE_NAME=STRINGSNP$CRORDER=3SNP$CRLENGTH=150SNP$CRPRECISION=150SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=Data StorageSNP$CRTYPE_NAME=STRINGSNP$CRORDER=4SNP$CRLENGTH=150SNP$CRPRECISION=150SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=Two Pass CalculationSNP$CRTYPE_NAME=STRINGSNP$CRORDER=5SNP$CRLENGTH=150SNP$CRPRECISION=150SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=Account TypeSNP$CRTYPE_NAME=STRINGSNP$CRORDER=6SNP$CRLENGTH=150SNP$CRPRECISION=150SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=Time BalanceSNP$CRTYPE_NAME=STRINGSNP$CRORDER=7SNP$CRLENGTH=150SNP$CRPRECISION=150SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=Data TypeSNP$CRTYPE_NAME=STRINGSNP$CRORDER=8SNP$CRLENGTH=150SNP$CRPRECISION=150SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=Variance ReportingSNP$CRTYPE_NAME=STRINGSNP$CRORDER=9SNP$CRLENGTH=150SNP$CRPRECISION=150SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=Source Plan TypeSNP$CRTYPE_NAME=STRINGSNP$CRORDER=10SNP$CRLENGTH=150SNP$CRPRECISION=150SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=Plan Type (FinStmt)SNP$CRTYPE_NAME=STRINGSNP$CRORDER=11SNP$CRLENGTH=150SNP$CRPRECISION=150SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=Aggregation (FinStmt)SNP$CRTYPE_NAME=STRINGSNP$CRORDER=12SNP$CRLENGTH=150SNP$CRPRECISION=150SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=Plan Type (WFP)SNP$CRTYPE_NAME=STRINGSNP$CRORDER=13SNP$CRLENGTH=150SNP$CRPRECISION=150SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=Aggregation (WFP)SNP$CRTYPE_NAME=STRINGSNP$CRORDER=14SNP$CRLENGTH=150SNP$CRPRECISION=150SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=FormulaSNP$CRTYPE_NAME=STRINGSNP$CRORDER=15SNP$CRLENGTH=150SNP$CRPRECISION=150SNP$CR$$SNPS_END_KEY*/
    insert into "C$_0Account"
         C1_ACCOUNT,
         C2_PARENT,
         C12_ALIAS__DEFAULT,
         C3_DATA_STORAGE,
         C9_TWO_PASS_CALCULATION,
         C6_ACCOUNT_TYPE,
         C14_TIME_BALANCE,
         C5_DATA_TYPE,
         C10_VARIANCE_REPORTING,
         C13_SOURCE_PLAN_TYPE,
         C7_PLAN_TYPE__FINSTMT_,
         C8_AGGREGATION__FINSTMT_,
         C15_PLAN_TYPE__WFP_,
         C4_AGGREGATION__WFP_,
         C11_FORMULA
    values
         :C1_ACCOUNT,
         :C2_PARENT,
         :C12_ALIAS__DEFAULT,
         :C3_DATA_STORAGE,
         :C9_TWO_PASS_CALCULATION,
         :C6_ACCOUNT_TYPE,
         :C14_TIME_BALANCE,
         :C5_DATA_TYPE,
         :C10_VARIANCE_REPORTING,
         :C13_SOURCE_PLAN_TYPE,
         :C7_PLAN_TYPE__FINSTMT_,
         :C8_AGGREGATION__FINSTMT_,
         :C15_PLAN_TYPE__WFP_,
         :C4_AGGREGATION__WFP_,
         :C11_FORMULA
    Thanks in advance!

    Right-clicking "data" on the model tab can you see the data?
    In your code there's written:
    P$CRLOAD_FILE=Y:/1 Metadata/Account//Account.csv
    Is it right the double slash before the file name?

  • Writing data from a CSV file in to table

    Hi All,
    I have a CSV (Comma Separated Values) file and i want to write its data in to the table.
    How can i get data from a CSV file.

    As Karthick suggested, you can use External Tables or Sql Loader functionality
    You can check this link for example on Sql Loader http://surachartopun.com/2007/10/example-sql-loader-some-data-into.html

  • SQL Loader to Load Multiple Tables from Multiple Files

    Hi
    I wish to create a control file to load multiple tables from multiple files
    viz.Emp.dat into emp table and Dept.dat into Dept table and so on
    How could I do it?
    Can I create a control file like this:
    OPTIONS(DIRECT=TRUE,
    SKIP_UNUSABLE_INDEXES=TRUE,
    SKIP_INDEX_MAINTENANCE=TRUE)
    UNRECOVERABLE
    LOAD DATA
    INFILE 'EMP.dat'
    INFILE 'DEPT.dat'
    INTO TABLE emp TRUNCATE
    FIELDS TERMINATED BY "|" OPTIONALLY ENCLOSED BY '"'
    (empno,
    ename,
    deptno)
    INTO TABLE dept TRUNCATE
    FIELDS TERMINATED BY "|" OPTIONALLY ENCLOSED BY '"'
    (deptno,
    dname,
    dloc)
    Appreciate a Quick Reply
    mailto:[email protected]

    Which operating system? ("Command Prompt" sounds like Windows)
    UNIX/Linux: a shell script with multiple calls to sqlldr run in the background with "&" (and possibly nohup)
    Windows: A batch file using "start" to launch multiple copies of sqlldr.
    http://www.pctools.com/forum/showthread.php?42285-background-a-process-in-batch-%28W2K%29
    http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/start.mspx?mfr=true
    Edited by: Brian Bontrager on May 31, 2013 4:04 PM

  • I need to import data from a CSV file to an Oracle table

    I need to import data from a CSV file to an Oracle table. I'd prefer to use either SQL Developer or SQL Plus code.
    As an example, my target database is HH910TS2, server is ADDb0001, my dB login is em/em, the Oracle table is AE1 and the CSV file is AECSV.
    Any ideas / help ?

    And just for clarity, it's good to get your head around some basic concepts...
    user635625 wrote:
    I need to import data from a CSV file to an Oracle table. I'd prefer to use either SQL Developer or SQL Plus code.SQL Developer is a GUI front end that submits code to the database and displays the results. It does not have any code of it's own (although it may have some "commands" that are SQL Developer specific)
    SQL*Plus is another front end (character based rather than GUI) that submits code to the database and displays the results. It also does not have code of it's own although there are SQL*Plus commands for use only in the SQL*Plus environment.
    The "code" that you are referring to is either SQL or PL/SQL, so you shouldn't limit yourself to thinking it has to be for SQL Developer or SQL*Plus. There are many front end tools that can all deal with the same SQL and/or PL/SQL code. Focus on the SQL and/or PL/SQL side of your coding and don't concern yourself with limitations of what tool you are using. We often see people on here who don't recognise these differences and then ask why their code isn't working when they've put SQL*Plus commands inside their PL/SQL code. ;)

  • Java Procedure  to load Oracle Table from flat file

    Hi,
    I am trying to load oracle table from data in flat file.
    Anybody help me out.
    I am using following code but it is giving invalid sql statement error
    try {     
            // Create the statement
          Statement stmt = conn.createStatement();
            // Load the data
         String filename = "c:\\temp\\infile.txt";
         String tablename = "TEST";
         // If the file is comma-separated, use this statement
         stmt.executeUpdate("LOAD DATA INFILE"  + "c:\\temp\\infile.txt" + "INTO TABLE "
         + "TEST" + " FIELDS TERMINATED BY ','");
                 stmt.close();
                 conn.close();
         } catch (SQLException e) {
              e.printStackTrace();
         }I will appriciate your help.
    Thanks.

    I tried the following too but getting same error.
    try {
                        // Create the statement
                        Statement stmt = conn.createStatement();
                        // Load the data
                        String filename = "c:\\temp\\infile.txt";
                        String tablename = "TEST";
                       // If the file is comma-separated, use this statement
                        stmt.executeUpdate("LOAD DATA INFILE \"" + filename + "\" INTO TABLE "
                         + tablename + " FIELDS TERMINATED BY ','");
                        //If the file is terminated by \r\n, use this statement
                        //stmt.executeUpdate("LOAD DATA INFILE \"" + filename + "\" INTO TABLE "
                        //+ tablename + " LINES TERMINATED BY '\\r\\n'");
                                               stmt.close();
                                               conn.close();
                   } catch (SQLException e) {
                        e.printStackTrace();
                   }Any Idea ?

  • Loading  a database table from a UNIX file

    hi,
    Need A program to load a database table from a UNIX file
    thnks.

    HI,
    report zmjud001 no standard page heading.
    tables: z_mver.
    parameters: test(60) lower case default '/dir/judit.txt'.
    data: begin of unix_intab occurs 100,
    field(53),
    end of unix_intab.
    data: msg(60).
    ***open the unix file
    open dataset test for input in text mode message msg.
    if sy-subrc <> 0.
    write: / msg.
    exit.
    endif.
    ***load the unix file into an internal table
    do.
    read dataset test into unix_intab.
    if sy-subrc ne 0.
    exit.
    else.
    append unix_intab.
    endif.
    enddo.
    close dataset test.
    ***to process the data. load the database table
    loop at unix_intab.
    z_mver-mandt = sy-mandt.
    z_mver-matnr = unix_intab-field(10).
    translate z_mver-matnr to upper case.
    z_mver-werks = unix_intab-field+10(4).
    translate z_mver-werks to upper case.
    z_mver-gjahr = sy-datum(4).
    z_mver-perkz = 'M'.
    z_mver-mgv01 = unix_intab-field+14(13).
    z_mver-mgv02 = unix_intab-field+27(13).
    z_mver-mgv03 = unix_intab-field+40(13).
    to check the data on the screen (this is just for checking purpose)
    write: / z_mver-mandt, z_mver-matnr, z_mver-werks, z_mver-gjahr,
    z_mver-perkz, z_mver-mgv01,
    z_mver-mgv02, z_mver-mgv03.
    insert z_mver client specified.
    *if the data already had been in table z_mver then sy-subrc will not be
    *equal with zero. (this can be *interesting for you - (this list is
    *not necessary but it maybe useful for you)
    if sy-subrc ne 0.
    write:/ z_mver-matnr, z_mver-werks.
    endif.
    endloop.
    1. This solution is recommended only if the database table is NOT a standard SAP database table .
    Cheers,
    Chandra Sekhar.

  • How can I import data from a csv file into databse using utl_file?

    Hi,
    I have two machines (os is windows and database is oracle 10g) that are not connected to each other and both are having the same database schema but data is all different.
    Now on one machine, I want to take dump of all the tables into csv files. e.g. if my table name is test then the exported file is test.csv and if the table name is sample then csv file name is sample.csv and so on.
    Now I want to import the data from these csv files into the tables on second machine. if I've 50 such csv files, then data should be written to 50 tables.
    I am new to this. Could anyone please let me know how can I import data back into tables. i can't use sqlloader as I've to satisfy a few conditions while loading the data into tables. I am stuck and not able to proceed.
    Please let me know how can I do this.
    Thanks,
    Shilpi

    Why you want to export into .csv file.Why not export/import? What is your oracle version?
    Read http://www.oracle-base.com/articles/10g/oracle-data-pump-10g.php
    Regards
    Biju

  • Problem in converting table data into CSV file

    Hi All,
    In my Process i need to convert my error table data into csv file,my data is converted as csv file by using OdisqlUnload function,but the column headers are not converted,i use another procedure for converting column headers but iam getting below error ...
    com.sunopsis.sql.SnpsMissingParametersException: Missing parameter string.find, string.find
    SQL: import string import java.sql as sql import java.lang as lang import re sourceConnection = odiRef.getJDBCConnection("SRC") output_write=open('C:/Oracle/Middleware/Oracle_ODI2/oracledi/pro/PRO.txt','r+') myStmt = sourceConnection.createStatement() my_query = "select * FROM E$_LOCAL_F0911Z1" my_query=my_query.upper() if string.find(my_query, '*') > 0: myRs = myStmt.executeQuery(my_query) md=myRs.getMetaData() collect=[] i=1 while (i <= md.getColumnCount()): collect.append(md.getColumnName(i)) i += 1 header=','.join(map(string.strip, collect)) elif string.find(my_query,'||') > 0: header = my_query[7:string.find(my_query, 'FROM')].replace("||','||",',') else: header = my_query[7:string.find(my_query, 'FROM')] print header old=output_write.read() output_write.seek(0) output_write.write (header+'\n'+old) sourceConnection.close() output_write.close()
    And i used below code for converting.......
    import string
    import java.sql as sql
    import java.lang as lang
    import re
    sourceConnection = odiRef.getJDBCConnection("SRC")
    output_write=open('C:/Oracle/Middleware/Oracle_ODI2/oracledi/pro/PRO.txt','r+')
    myStmt = sourceConnection.createStatement()
    my_query = "select FROM E$_COMPANY"*
    *my_query=my_query.upper()*
    *if string.find(my_query, '*') > 0:*
    *myRs = myStmt.executeQuery(my_query)*
    *md=myRs.getMetaData()*
    *collect=[]*
    *i=1*
    *while (i <= md.getColumnCount()):*
    *collect.append(md.getColumnName(i))*
    *i += 1*
    *header=','.join(map(string.strip, collect))*
    *elif string.find(my_query,'||') > 0:*
    *header = my_query[7:string.find(my_query, 'FROM')].replace("||','||",',')*
    *else:*
    *header = my_query[7:string.find(my_query, 'FROM')]*
    *print header*
    *old=output_write.read()*
    *output_write.seek(0)*
    *output_write.write (header+'\n'+old)*
    *sourceConnection.close()*
    *output_write.close()*
    Any one can you help regarding this
    Edited by: 30021986 on Oct 1, 2012 6:04 PM

    This may not be an option for you but in pinch you may want to consider outputing your data to an MS Spreadsheet, then saving it as a CSV. It's somewhat of a cumbersome process, but it will get you by for now.
    You will need to change your content type to application/vnd.ms-excel.
    <% response.setContentType("application/vnd.ms-excel"); %>

  • How can i import contacts from a csv file to "iCloud Contacts"?

    How can I import contacts from a csv file to "iCloud Contacts"?

    The only way I know of to import cells from a csv file is by creating a new file.  But then you can select the desired cells and copy them to the other file.  I just did it to be sure it works.
    1. Create the new spreadsheet file via the upload command.
    2. Select the cells (table) that you want to move to the other file and press command+C (copy).
    3. Close the new file and open the existing file.
    4. Select the top/right cell of the area to receive the copied "table" and press commant+V (paste).
    I hope this is what you're trying to do!

Maybe you are looking for