Loading csv file trying to replace double quotes

Hi, I am trying to load a csv file with a field with double qoutes that I want to replace the double qoutes to one. The CSV file I will enter
"TEST,2345" in a field and when it loads its as ""TEST,2345""
So I got this code to handle it.
Pattern quotesRegex = Pattern.compile("\"\"");
          Matcher m = fieldRegex.matcher(line);
          while (m.find()) {
               String field;
               if (m.group(1) != null) {
                    // If a quoted string was matched replace escaped double quote,
                    // "" with "
                    field = quotesRegex.matcher(m.group(1)).replaceAll("\"");
else {
                    field = m.group(2);
               fields.add(field.trim());
I want to change a line like this
D,,""TEST,2345"",46,,
to
D,,"TEST,2345",46,,
but afterwards nothing has changed the record looks as below
D,,""TEST,2345"",46,,
Whats wrong with this?
thanks

I simply created a simple csv file with one field that I entered a double qoute of "TEST,2345"
Later when reading in the file(using the code I pasted in) I can inspect it and its """TEST,2345"""
The relaceAll doesnt seem to change anything(nor did my code). So I was stumped. thanks

Similar Messages

  • Loading External files in Oracle - error (double quotes on columns)

    I managed to successfully load some external (Excel ) files in my Oracle database, but when I queried the table, I see that some of the columns have double quotes on them. Any idea how to remedy this problem?

    damorgan wrote:
    OPTIONALLY ENCLOSED BY double quotes in your syntax to remove them.
    http://www.morganslibrary.org/reference/externaltab.html
    Damorgan,
    Thank you!

  • How to replace double quotes with a single quote in a string ?

    Hi All:
    Can some one tell me how to replace double Quote (") in a string with a single quote (') ? I tried to use REPLACE function, but I couldn;t get it worked.
    My example is SELECT REPLACE('STN. "A"', '"', ''') FROM Dual --This one throws an error
    Thanks,
    Dima.

    Whether it is maybe not the more comfortable way, I like the quoting capabitlity from 10g :
    SQL> SELECT REPLACE('STN. "A"', '"', q'(')') FROM Dual;
    REPLACE(
    STN. 'A'{code}
    Nicoals.                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Firefox is replacing double quotes with single quotes.

    In WordPress and at other sites where I input and save text, Firefox is replacing double quotes with single quotes when I save. It's also showing double quotes as single quotes on websites. I tried uninstalling and reinstalling, and it's still happening.

    Do you have the needed font installed?
    *http://en.wikipedia.org/wiki/Punctuation

  • Load .csv file data with OWb Process flow using Web

    Hi,
    I Have a file in my local machine( Machines on multiple user's), need to load data through Web user interface.
    Let's say have a web page with multiple radio buttons respective to different sources, by clicking on each button will pass the path of .csv file to through Application, (API or Java programming interface) execute owb Process flow as a accepting file path as a input parameter to execute for loading purpose.
    Should facilitate view data, Update data through web based on user requests.
    Need your guidence how can i implement this with OWb 11g R2.
    Assuming with Web browser functionality. Please confirm it and if yes, please throw some light how could be the steps to implement.
    Thanks

    Hi David,
    Thanks for your reply.
    Undersatnd your proposed solution.But my requirement should be as follows.
    1. Currently under consideration using web page likely to be implement with Java, allowing users to load .csv file data into staging area.(Loading flat file into Data abse table)
    Case 1, Assuming OWB software is not installed on user machine. I think no.
    Is it possible through web page (this case Java page) to trigger java procedure/Pl/SQl procedure or integration of both to laod data into staging area.If yes, how it could effect performance of data load with 1 GB file.
    Case 2, OWb client software installed on User machine, while runtime passing parameters means passing manually?
    In case it is automated, how should i pass machine name & Path to owb runtime web browser.
    Could you please show me guidence how should I acheive this functionality with APEX customization part?
    Thanks agin for your support.
    Anil

  • What is limit to load csv file for Apex Utility?

    What is limit to load csv file for Apex Utility?
    How many records can I load through apex load utility?
    I am loading csv files.
    Thank you.

    Hi,
    You download the report that is displayed in APEX which is limited to 65k. There may be some way of creating a custom file based off the table rather than using APEX's built in export to csv option but I don't know of any being released. Denes produced an export to .xls option but I don't know how many rows that caters too: http://htmldb.oracle.com/pls/otn/f?p=31517:108:1512181285516724::NO:: -- I assume 65k too though.
    Mike

  • How to load csv file to table using ssis

    Hi,
    i have loaded the csv file to table using ssis, it is working file but record is mismatch.
    source data :
    col1 col2 col3 col4
    aa, bb, this is sample,data for the details, this is 
    column delimiter - comma
    col3 - record contains comma. so col3 record after the comma is added with the as col4
    i need the col3 record with comma.
    so what is the column delimiter will use ?
    Regards,
    abdul Khadir

    Hi Abdul,
    Based on your description, you want to distinguish a comma is used for column separator or used in address column in a text file, then load the data from the text file to SQL Server table.
    As per my understanding, if you can replace the comma column separator to another delimiter like semicolon (;), just do it. Then we can select Semicolon {;} as Column delimiter for the Flat File Connection Manager. Or ensure all columns are enclosed in double
    quotes ("). Then we can set the double quotes (") as Text qualifier for the Flat File Connection Manager, and the commas will be loaded as part of the string fields.
    If you can't have that done, because computers don't know the context of the data, you would have to come up with some kind of rules that decides when a comma represents a delimiter, and when it is just part of the text. I think a custom script component
    would be necessary to pre-process the data, identify where a comma is part of an address, and then treat that as one field.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Load CSV file into a table when a button is clicked by the user

    Hello,
    Can anyone please help me out with this issue, I have a form where in a user comes and uploads a CSV file and clicks a button, when the button is clicked - it should load the CSV file data into the database table for the corresponding columns.
    Can anyone please suggest me a possible solution or an approach.
    Thanks,
    Orton
    Edited by: orton607 on May 5, 2010 2:00 PM

    thanks fro replying.
    I have tried your changes but its not working. One more question is that I am having one column which contains commas, when I tried to load the file its failing. I think its the problem with commas. So I have changed the code to use the replace function for that column, then also its not working. Can anyone please suggest a possible approach. Below is my source code for your reference.
    DECLARE
    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 wwv_flow_global.vc_arr2;
    v_rows NUMBER;
    v_sr_no NUMBER := 1;
    l_cnt BINARY_INTEGER := 0;
    l_stepid NUMBER := 10;
    BEGIN
    delete from sample_tbl;
    -- Read data from wwv_flow_files</span>
    select blob_content into v_blob_data from wwv_flow_files
    where last_updated = (select max(last_updated) from wwv_flow_files where UPDATED_BY = :APP_USER)
    and id = (select max(id) from wwv_flow_files where updated_by = :APP_USER);
    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 := wwv_flow_utilities.string_to_table (v_line);
    -- Insert data into target table </span>
    EXECUTE IMMEDIATE 'insert into sample_tbl(col1..col12)
    values (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12)'
    USING
    v_sr_no,
    v_data_array(1),
    v_data_array(2),
    v_data_array(3),
    v_data_array(4),
    v_data_array(5),
    v_data_array(6),
    v_data_array(7),
    v_data_array(8),
    REPLACE(v_data_array(9), ':', ','),
    to_date(v_data_array(10),'MM/DD/YYYY'),
    v_data_array(11);
    -- Clear out
    v_line := NULL;
    v_sr_no := v_sr_no + 1;
    l_cnt := l_cnt + SQL%ROWCOUNT;
    END IF;
    END LOOP;
    COMMIT;
    l_stepid := 20;
    IF l_cnt = 0 THEN
    apex_application.g_print_success_message := apex_application.g_print_success_message || ' Please select a file to upload ' ;
    ELSE
    apex_application.g_print_success_message := apex_application.g_print_success_message || 'File uploaded and processed ' || l_cnt || ' record(s) successfully.';
    END IF;
    l_stepid := 30;
    EXCEPTION WHEN OTHERS THEN
    ROLLBACK;
    apex_application.g_print_success_message := apex_application.g_print_success_message || 'Failed to upload the file. '||REGEXP_REPLACE(SQLERRM,'[('')(<)(>)(,)(;)(:)(")('')]{1,}', '') ;
    END;
    Below is the function which I am using to convert hex to decimal
    create or replace function hex_to_decimal( p_hex_str in varchar2 ) return number
    is
    v_dec number;
    v_hex varchar2(16) := '0123456789ABCDEF';
    begin
    v_dec := 0;
    for indx in 1 .. length(p_hex_str)
    loop
    v_dec := v_dec * 16 + instr(v_hex,upper(substr(p_hex_str,indx,1)))-1;
    end loop;
    return v_dec;
    end hex_to_decimal;
    thanks,
    Orton

  • Unable to Load CSV file with comma inside the column(Sql Server 2008)

    Hi,
    I am not able load an CSV file with Comma inside a column. 
    Here is sample File:(First row contain the column names)
    _id,qp,c
    "1","[ ""0"", ""0"", ""0"" ]","helloworld"
    "1","[ ""0"", ""0"", ""0"" ]","helloworld"
    When i specify the Text Qualifier as "(Double quotes) it work in SQL Server 2012, where as fail in the SQL Server 2008, complaining with error:
    TITLE: Microsoft Visual Studio
    The preview sample contains embedded text qualifiers ("). The flat file parser does not support embedding text qualifiers in data. Parsing columns that contain data with text qualifiers will fail at run time.
    BUTTONS:
    OK
    I need to do this in sql server 2008 R2 with Service pack 2, my build version is 10.50.1600.1.
    Can someone let me know it is possible in do the same way it is handle in SQL Server 2012?
    Or
    It got resolved in any successive Cumulative update after 10.50.1600.1?
    Regards Harsh

    Hello,
    If you have CSV with double quotes inside double quotes and with SSIS 2008, I suggest:
    in your data flow you use a script transformation component as Source, then define the ouput columns id signed int, Gp unicode string and C unicode string. e.g. Ouput 0 output colmuns
    Id - four-byte signed
    gp - unicode string
    cc - unicode string
    Do not use a flat file connection, but use a user variable in which you store the name of the flat file (this could be inside a for each file loop).
    The user variable is supplied as a a readonly variable argument to the script component in your dataflow.
    In the script component inMain.CreateNewOutputRows use a System.IO.Streamreader with the user variable name to read the file and use the outputbuffer addrow method to add each line to the output of the script component.
    Between the ReadLine instraction and the addrow instruction you have to add your code to extract the 3 column values.
    public override void CreateNewOutputRows()
    Add rows by calling the AddRow method on the member variable named "<Output Name>Buffer".
    For example, call MyOutputBuffer.AddRow() if your output was named "MyOutput".
    string line;
    System.IO.StreamReader file = new System.IO.StreamReader( Variables.CsvFilename);
    while ((line = file.ReadLine()) != null)
    System.Windows.Forms.MessageBox.Show(line);
    if (line.StartsWith("_id,qp,c") != true) //skip header line
    Output0Buffer.AddRow();
    string[] mydata = Yourlineconversionher(line);
    Output0Buffer.Id = Convert.ToInt32(mydata[0]);
    Output0Buffer.gp = mydata[1];
    Output0Buffer.cc = mydata[2];
    file.Close();
    Jan D'Hondt - SQL server BI development

  • Error loading csv file from application server

    Hi all,
    While uploading a csv file from the application server to psa we are getting the following error,
    Error 2 while splitting CSV data record
    Message no. RSDS_ACCESS011
    Diagnosis
    Error 2 occurred while splitting the CSV data record 1
    1 = Could not find a closing escape character
    2 = Invalid escape character
    3 = Conversion error
    4 = Other error
    System Response
    The function was terminated.
    Procedure
    Check the values of the data separator and escape sign, and try again.
    But i've checked the file and the escape sign, data seperator in it also. Everything is fine.  The same file we are able to load successfully in quality system.
    How to solve this error??
    Thanks in advance.

    Hi BI consultant:
       Could you please provide more details?
    For example:
    1.Is your P application server a UNIX flavor? (Solaris, AIX, UX, Linux)
       If yes..
             2. Are you able to see the contents of the file correctly with a "cat" or "vi" command? (at operating system level).
                   If no...
                         3. Did you upload the csv flat file to the server via FTP?
                                If yes...
                                     4. Did you use the "binary" or the "ascii" parameter on the FTP command used to upload the file?
    Probably you need to upload the CSV file again to your application server and make sure you can se the file contents ("cat" or "vi" command) before trying to execute the InfoPackage.
    Regards,
    Francisco Milán.
    Edited by: Francisco Milan on Jun 3, 2010 11:13 AM

  • Replacing " (double quote) with ' (single quote)

    Hi there,
    I have the following method to manipulate user input. All I want to do is, to replace the double quote with a single quote. The implementation I tried was,
    this.replace(desc, "\"", "'");
    This does not work for me. It jsut removes the double quote and does not introduces the single quote. Could any one please advise?
    Thanks,
    Des
    public static String replace(String line, String oldString, String newString) {
              if(line != null && oldString != null && newString != null) {
                   int index = 0;
                   while ((index = line.indexOf(oldString, index)) >= 0) {
                        line = line.substring(0, index) +
                             newString +
                             line.substring(index + oldString.length());
                        index += newString.length();
              return line;
         }

    Bad luck.. I am unable to get it still.
    This is the code I am using (implemetation is in a JSP. I am using this code to test it).
    public class Test{
    public static void main(String args[]){
         String s = args[0];
         Test t = new Test();
         String doubleQuote = "\"";
         System.out.println(" output :"+ t.replace(s,doubleQuote,"'"));
         //System.out.println(" output :"+ t.replace(s,"\"","'"));
         //System.out.println(" output :"+ t.replace('"', '\''));
    public static String replace(String line, String oldString, String newString) {
              if(line != null && oldString != null && newString != null) {
                   int index = 0;
                   while ((index = line.indexOf(oldString, index)) >= 0) {
                             System.out.println(" line count :");
                        line = line.substring(0, index) +
                             newString +
                             line.substring(index + oldString.length());
                        index += newString.length();
              return line;
    }mshn02
    The main problem is I am stuck with the server's version of Java (which I have no control on it). I could not use 1.4.2

  • Issue loading CSV file into HANA

    Hi,
    From last couples of weeks i am trying to load my CSV file into HANA Table, but i am unable to succeed.
    I am getting error "Cannot open Control file, /dropbox/P1005343/CRM_OBJ_ID.CTL". I have followed each and every step in SDN, still I could not load data into my HANA table.
    FTP: /dropbox/P1005343
    SQL Command:
    IMPORT FROM '/dropbox/P1005343/crm_obj_id.ctl'
    Error:
    Could not execute 'IMPORT FROM '/dropbox/P1005343/crm_obj_id.ctl''
    SAP DBTech JDBC: [2]: general error: Cannot open Control file, /dropbox/P1005343/crm_obj_id.ctl
    Please help me on this
    Regards,
    Praneeth

    Hi All,
    I have successfully loaded the file into HANA database in folder P443348 but while importing file, I am getting the following error message such as
    SAP DBTECH JDBC: [2]  (at 13) : general error: Cannot open Control file, "/P443348/shop_facts.ctl"
    This is happening while I am executing the following import statement
    IMPORT FROM '/P443348/shop_facts.ctl';
    I have tried several options including changing the permissions of the folders and files to no success. As of now my folder has full access, which is 777
    Any help would be greatly appreciated so that I can proceed further
    Thanks
    Vamsidhar

  • How to handle comma present in any filed while loading CSV file in APEX

    I am trying to import excel sheet data into a table. I have followed steps mentioned in below link and they work just fine with one exception.
    http://avdeo.com/2008/05/21/uploading-excel-sheet-using-oracle-application-express-apex/
    Exception is related to presense of comma (,) in any particular filed like- Address.
    How can I handle this situation? I am using APEX 3.2
    Thanks,
    Abhi

    Yes this is correct.
    but problem will occur when e.g check the foll. string.
    (1001,And I quote "This, will work")
    Here it is a comm(,) in b/w "This and will".
    due to this sqlldr interpret it as end of field. and throws an error.
    I had gone through expert one on one oracle, what it maintioned as,
    put an extra double quotes( " ) like " " to enclosed the double quoted string.
    This works fine. For small data it can be done manually.
    But for large data what condition can be put in the ctl file to achieve this?
    or is there any other way to achieve this?
    Thank you.

  • How to load CSV files into HANA

    1.- Create an CSV file with your data
    2.- Copy the file to dropbox/yourname inside the HANA box
    3.- Create a table in HANA with the structure of your file
    4.- create the control file BBB with the following information:
    import data
    into table XXX."YYY"
    from 'ZZZ.csv'
    record delimited by '\n'  
    fields delimited by ','
    optionally enclosed by '"'
    error log 'Text_Tables.err'
    Where XXX is your schema, YYY is your HANA Table and ZZZ is your file
    5.- Open an Script File and write the following:
    LOAD FROM '/filer/dropbox/yourname/BBB.ctl';
    where BBB is the name of your control file
    Greetings,
    Blag.

    With the recent upgrade to the HANA SP3...the method to upload files to HANA has been slightly changed...so here's the updated tutorial:
    1.- Create an CSV file with your data
    2.- Copy the file to the HANA Dev Center
    3.- Open a FTP connection to ftp.sapdevcenter.com
    (You can find the user name and password by doing a select to SYSTEM.FTP_SERVER)
    and....*Don't paste the Username or password here or any other place!*
    4.- Create a folder with your name on the FTP site and copy the file there
    4.- Create a table in HANA with the structure of your file
    5.- create the control file BBB with the following information:
    import data
    into table XXX."YYY"
    from 'ZZZ.csv'
    record delimited by '\n'
    fields delimited by ','
    optionally enclosed by '"'
    error log 'Text_Tables.err'
    Where XXX is your schema, YYY is your HANA Table and ZZZ is your file
    5.- Open an Script File and write the following:
    IMPORT FROM '/dropbox/yourname/BBB.ctl';
    where BBB is the name of your control file
    I just test it and it works...if it doesn't work for you, please let me know
    Greetings,
    Blag.

  • How to load csv file in oracle table

    Hi,
    i have csv files to which i want to load the csv file data and table structure in oracle. my csv files on the window machine but database is runing on ibm aix.so how to do it please any one can help me about. thanks a lot in advance
    i know th syntax below
    $sqlldr userid=username/password control=<filename> log=<log filename>

    Hello,
    Yes, with SQL*Loader you can do it.
    But first you have to create a Table into your database with columns and datatype matching
    the content of you "csv" file.
    Then, you'll have to prepare a control file and use the option fields terminated by "," as it's
    a "csv" format.
    Then, you could execute your statement.
    Please, find enclosed a link with some example about SQL*Loader and "csv" file:
    [http://www.orafaq.com/wiki/SQL*Loader_FAQ]
    Hope this help.
    Best regards,
    Jean-Valentin

Maybe you are looking for