Script to remove commas from a csv file

Hi all

I have the following output to a csv file:

VM, VI-SVC-VM014, 0000ed, 0000ee,
VM, VI-SVC-VM103, 0000f3, 0000f2,
VM, VI-SVC-VM104, 0000f6, 0000f6,
LDEV, SVC PROD Cluster01, 0000e2, 0x04
LDEV, SVC PROD Cluster01, 0000de, 0x00
LDEV, SVC PROD Cluster01, 0000df, 0x01
LDEV, SVC PROD Cluster01, 0000e2, 0x04

I'm looking to remove commas end so that the output looks like this:

VM, VI-SVC-VM014, 0000ed, 0000ee
VM, VI-SVC-VM103, 0000f3, 0000f2
VM, VI-SVC-VM104, 0000f6, 0000f6
LDEV, SVC PROD Cluster01, 0000e2, 0x04
LDEV, SVC PROD Cluster01, 0000de, 0x00
LDEV, SVC PROD Cluster01, 0000df, 0x01
LDEV, SVC PROD Cluster01, 0000e2, 0x04

The column length for each line (given the number of objects), modular in this output. By this, I mean that some outputs will be like this:

VM, VI-SVC-VM014, 0000ed, 0000ee, 0000ef
VM, VI-SVC-VM104, 0000f6, 0000f6

VI-SVC-VM104, 0000f6, 0000f5, 0000f7, VM, 0000f4
LDEV, SVC PROD Cluster01, 0000e2, 0x04
LDEV, SVC PROD Cluster01, 0000de, 0x00

Is it possible to import the data (get-content), delete all non alpha-numeric end of line? Maybe there is an easier way.

Thank you

Rob.

Try something like

Get-Content file.csv | %{
  $_.TrimEnd(',')
} | Set-Content newfile.csv

Tags: VMware

Similar Questions

  • Configure vswitches from a .csv file - problem

    I have a script that works very well for the installation of my virtual past by using the updatevirtualswitch method. (Thanks to LucD, see here: ) http://communities.VMware.com/message/1556669#1556669 )

    I now want to go further and to feed my script with variables from a .csv file.

    It works fine for all, with the exception of the definition of vmnic. Description of the problem:

    Excerpt from my .csv file:

    lannics; dmznic1; dmznic2; dmznic3; storagenics; vmotionnics;

    @("vmnic0"); @("vmnic1", "vmnic2");

    Then import the settings from the csv file, example:

    $lannics = $parameterfile.dmznic1

    Now, if I check what's in $dmznic1, I have the good: @("vmnic1", "vmnic2")

    But it seems to be a string, not a true table. Therefore, I can not pass it to my updatevirtualswitch function:

    function standardvswitch {}

    Param ($esx, $vs, [string []] $dmznic1)

    ....

    $ns. UpdateVirtualSwitch ($vs, $vsSpec)

    }

    So the question is: how could I get my .csv file information, so that it can be used for a definition of vmnic compatible with the UpdateVirtualSwitch method?

    Thanks for your help or ideas!

    I've done a few tests more and saw that my previous solution does not work. "But one that follows). I'll try to explain how it works. In the .csv file, a semicolon is used as a field separator. This means that you can use a comma in a field to separate the members of the group. The Import-CSV cmdlet reads the .csv file and - separator "," parameter instructs the cmdlet that a semicolon is the field delimiter. The output of the Import-CSV cmdlet is piped in a ForEach-Object cmdlet. In the scriptblock ForEach-Object according to the value of the dmznic1 property string is shared by the comma, so each string before, between and after the comma will become a member of separate table. This table is assigned to the dmznic1 property. Loop loop through all the members of the Group and displays them on separate lines. So you can see that it is really a picture.

    Import-CSV -Path LanNics.CSV -Delimiter ";" | `
    ForEach-Object {
      $_.dmznic1 = ($_.dmznic1).split(",")
      for ($i=0;$i -lt $_.dmznic1.length; $i++) {
        Write-Output $_.dmznic1[$i]
      }
    }
    

    See the attached screenshot for output.

    I think that this solution is more beautiful that create a different column for each vmnic because in my solution you don't have to know in advance how many cards you have.

    Post edited by: RvdNieuwendijk

  • Unable to display data from a csv file data store

    Hi all

    I'm using ODI 11 g. I'm trying to import metadata from a csv file. To do this, I have created physical and logical diagrams corresponding. Context is global.

    Then, I created a model and a data store. Now, after reverse engineering data store, I got the file headers and I changed the data type of columns to my requirement and then tried to view the data in the data store. I am not getting any error, but can't see all the data. I am able to see only the headers.

    Even when I run the interface that loads data into a table, its operation without error, but no data entered...

    But the data is present in the source file...

    Can you please help me how to solve this problem...

    Hi Phanikanth,

    Thanks for your reply...

    I did the same thing that you suggested...

    In fact, I'm working on the ODI in UNIX environment. So I went for the record separator on UNIX option in the files of the data store tab and now its works well...

    in any case, once again thank you for your response...

    Thank you best regards &,.

    Vanina

  • Update of field Notes from a csv file

    Hello

    I want to update the Notes field for all of the virtual machines in my environment from a .csv file.  To do this, I did and the export of my environment in a file .csv using this command:

    Get - VM | Select Name, Notes | Export-Csv-path "c:\output\notes.csv" - NoTypeInformation

    I now have a list of all virtual machines and their existing Notes.  I manually changed the notes fields keeping the existing descriptions and adding, for all the virtual machines that had no notes.  I would now like to merge the changes into vCenter and to crush any descriptions in vCenter but my code is any error on:

    Import-Csv "c:\output\notes.csv" | % {Set - VM $_.} VMName-note $_. {Note - confirm: $false}

    Any ideas?

    Untitled.jpg

    Well, the field of your CSV is 'Name', not "VMName".

    So, try:

    Import-Csv "c:\output\notes.csv" | % {Get - VM $_.} Name | Set-VM-note $_. {Note - confirm: $false}

  • If I convert a file in a file PDF Microsoft Word can I remove photos from the converted file

    If I convert a file PDF Microsoft Word can I remove photos from the converted file?

    Hi sutterrot,

    After a conversion from PDF to Word, you can download the converted file locally on your computer.

    You can then select the "Enable editing" button and then remove images/texts or make any other changes.

    Kind regards

    Ana Maria

  • Remove the last comma before reading csv files

    Hello

    I'm working on a VI that reads a lot of files csv (created by an application) using the built-in "worksheet File.vi reading" before combining in a report by using the excel report generation tool. 'All lines' are read in the csv file by using the worksheet File.vi reading.

    There are cases of csv files, where there an unwanted comma to the end of the line and an extra cell (with no data) appears in the final report. I was wondering if there is an easy way to remove it (rather than passing through each line and get rid of it).

    Thank you!

    You will need to go through each line, look at the last element and delete it if it is an empty string.  But a loop, it's easy:

    Read the spreadsheet, get 2D array of strings.  For each line, download the last element.  Test if she is a Virgin.  If so, remove it from the table.  If this is not the case, switch the blank table.

  • Delete snapshots by using data from a csv file

    I have a csv file that was exported in the form of:

    VM

    SERV1

    serv2

    SERV3

    (The file name is snaps4.csv)

    I want to delete the associated clichés a vm in this file csv; However I can't get anything to work.  Is the closest I've come by manually removing the header in the csv file (i.e. VM) then using the get-content command.

    $vms = get-Content C:\scripts\Output\snaps.csv

    Get-Snapshot - $vms vm | Remove-Snapshot - RemoveChildren-confirm: $false

    The above command works, but I have to remove the header first (which I am fine with, if I do this, but I'm trying to automate this process for people of our operations and have a manual step is not ideal).

    Someone help me?  I know I'm missing just something simple here, but can't understand it.


    Have you tried it?

    Import-Csv C:\scripts\Output\snaps.csv | %{

    Get-Snapshot - vm $_. VM | Remove-Snapshot - RemoveChildren-confirm: $false

    }

  • Add-adgroupmember are ZERO values as possible when you import users from a csv file?

    I run the PS command against a csv file containing a list of ad groups followed by ADUsers below.

    The script works very well as long as all fields are filled out, there at - it a command / switch that ignores a value not as such?

    import-csv c:\admin\powershell\ADGroupMembers.csv | foreach {add-adgroupmember-identity $_.} {Ad group $_.member1, $_.member2, $_.member3, $_.member4, $_.member5}
    ContentsADGroup of CSV file member1, member2, Member3, Member4, Member5 AD-Test1, Minnie, Mickey, Donald, Daisy, goofy AD-Test1, Minnie, Mickey, Donald, Minnie, Mickey, Donald, Pete, AD-Test1, Spike

    Hello

    Your question is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for Exchange Server on Technet. Please post your question in the Technet forums. You can follow the link to your question:

  • Analysis 1 row into two lines from a CSV file

    Hello

    Im trying to read a csv of the external table data in a table target.

    the problem is, I have a few lines, two names and names separated by spaces zwo (aspect ID2 and ID4)

    the csv data have this format:

    Source CSV file

    ID1 | "" Max Miller ' | "Lyonerstr 99" | " "1000" | " "" Berlin "| "' The Germany.

    ID2. «Hans Meyer Heidi Meyer «|» "Lyonerstr 100" | " "1000" | " "" Berlin "| "' The Germany.

    ID3 | "" Stefan Tek | "Lyonerstr 200" | " "1000" | " "" Berlin "| "' The Germany.

    ID4. ' José María Acero Acero ' |. ' "" Abcstr 111 | "2000" | " "" Hamburg ". "' The Germany.

    Target table

    ID1 | Max Miller | 99 Lyonerstr | 1000 | Berlin | Germany

    ID2. Hans Meyer | Lyonerstr 100 | 1000 | Berlin | Germany

    ID2. Heidi Meyer | Lyonerstr 100 | 1000 | Berlin | Germany

    ID3 | Stefan Tek | Lyonerstr 200 | 1000 | Berlin | Germany

    ID4. José Acero | Abcstr 111 | 2000. Hamburg | Germany

    ID4. Maria Acero | Abcstr 111 | 2000 "|" Hamburg | Germany

    Thank you very much.

    with

    external_table as

    (select 'ID1' u_id, f_l_name 'Max Miller', ' Lyonerstr 'address, zip ' 1000' 99, "Berlin" city, country "Germany" in double union ")

    Select 'ID2', 'Hans Meyer Heidi Meyer', ' Lyonerstr 100 ', ' 1000', 'Berlin', 'Germany' of the dual union all.

    Select 'ID3', "Stefan Tek", "Lyonerstr 200 ', ' 1000', 'Berlin', 'Germany' of the dual union all.

    Select "ID4", 'José Acero Acero Maria', ' Abcstr 111 ', ' 2000', 'Hamburg', 'Germany' from dual.

    )

    Select u_id, f_l_name, address, zip, city, country

    from (select u_id,

    -case when instr (f_l_name,' ') > 0

    so to case when level = 1

    then substr (f_l_name, 1, instr (f_l_name,' ')-1)

    of another substr (f_l_name, instr (f_l_name,' ') + 2)

    end

    another case when level = 1

    then f_l_name

    end

    end f_l_name

    address, zip, city, country

    of external_table

    connect by level<=>

    and prior u_id = u_id

    and the previous address = address

    zip and rar = prior

    and prior city = city

    and prior country = country

    and prior sys_guid() is not null

    )

    where f_l_name is not null

    U_ID F_L_NAME ADDRESS ZIP CITY COUNTRY
    ID1 Max Miller 99 Lyonerstr 1000 Berlin Germany
    ID2 Hans Meyer Lyonerstr 100 1000 Berlin Germany
    ID2 Heidi Meyer Lyonerstr 100 1000 Berlin Germany
    ID3 Stefan Tek Lyonerstr 200 1000 Berlin Germany
    ID4 José Acero Abcstr 111 2000 Hamburg Germany
    ID4 Maria Acero Abcstr 111 2000 Hamburg Germany

    Concerning

    Etbin

  • Helps to replace a string in a txt file with a string from a csv file

    Hi all

    I worked on the script following since a few days now, determined to exhaust my own knowledge before asking for help... Unfortunately, it didn't take very long to exhaust my knowledge :-(

    Basically, I need to replace a value in a single file (raw.txt) with the value of another file (userids.csv) when a variable is. Then I released the results of a third file.

    To do this, I divided the "raw" file into variables using the ',' as the separator, the problem is that some variables are intentionally empty, where the fi $variable = "statements.

    It is currently what I want to do but only when the userids.csv file contains a single line. It is obviously because of the foreach ($user in import)... What I need to figure out is how to loop through the file raw.txt, text replacement when a variable in the user ID file is the text in raw.txt... I hope that makes sense?

    The user ID file is in the following format - user, service, Dept that can contain dozens of lines

    I would appreciate any pointers :-)

    See you soon

    # Treatment
    $importraw = get-content i:\raw.txt
    $import = import-csv i:\userids.csv-en-tete UserAccount, functional, Dept

    {foreach ($user in $import)
    $useraccount = $user. UserAccount
    $userfunction = $user. Functional
    $userdept = $user. Dept
    {foreach ($line in $importraw)
    $first, $second, $third, $fourth, $fifth, $sixth, $seventh, $eighth, $ninth = $line - split(",")
    $linesproc = $linesproc + 1
    If ($sixth - eq ") {}
    $temp6 = "6TEMP".
    Write-Host "field Null detected - assigning temporary value:"$temp6 ".
    $sixth = $temp6 # the assignment of a temporary value so that - statement to replace later works
    }
    If ($seventh - eq ") {}
    $temp7 = "7TEMP".
    Write-Host "field Null detected - assigning temporary value:"$temp7 ".
    $seventh = $temp7 # the assignment of a temporary value so that - statement to replace later works
    }
    If ($fifth - eq $user.) UserAccount) {}
    $line - $seventh, replace $user. Dept | Add content i:\Output.txt
    }
    else {}
    $line - $seventh, replace "/ / customer. Add content i:\Output.txt
    }
    }

    }

    Try the attached version.

    The problem, in my opinion, was in nested ForEach loops.

    Instead I've implemented with a lookup table

  • How can I extract the data from a csv file and insert it into an Oracle table? (UTL_FILE)

    Hi, please help me whit this query

    Im trying to extrate the data in a file csv and im using the ULT_FILE package
    I have this query that read the file and the first field, but if the field has a different length does not work as it should

    For example if I had this .csv file:

    1, book, laptop

    2, pen, Eraser

    3, notebook, paper

    And in the table, I had to insert like this

    ID descrption1 description2

    laptop 1 book

    Eraser pen 2

    paper laptop 3

    For now, I have this query, which displays only with DBMS:

    Declare

    -Variables

    Cadena VARCHAR2 (32767).

    Vfile UTL_FILE. TYPE_DE_FICHIER;

    Dato varchar2 (200);                                             -Date

    dato1 varchar2 (200);

    dato2 varchar2 (200);

    Identifier varchar2 (5): = ', ';                             -Identifier (en)

    v_ManejadorFichero UTL_FILE. TYPE_DE_FICHIER;     -For exceptions

    -Table variables

    I_STATUS GL_INTERFACE. % OF STATUS TYPE.

    I_LEDGER_ID GL_INTERFACE. TYPE % LEDGER_ID;

    I_USER_JE_SOURCE_NAME GL_INTERFACE. TYPE % USER_JE_SOURCE_NAME;

    I_ACCOUNTING_DATE GL_INTERFACE. TYPE % ACCOUNTING_DATE;

    I_PERIOD_NAME GL_INTERFACE. TYPE % PERIOD_NAME;

    I_CURRENCY_CODE GL_INTERFACE. CURRENCY_CODE % TYPE;

    I_DATE_CREATED GL_INTERFACE. DATE_CREATED % TYPE;

    I_CREATED_BY GL_INTERFACE. CREATED_BY % TYPE;

    I_ACTUAL_FLAG GL_INTERFACE. TYPE % ACTUAL_FLAG;

    I_CODE_COMBINATION_ID GL_INTERFACE. TYPE % CODE_COMBINATION_ID;

    I_ENTERED_DR GL_INTERFACE. TYPE % ENTERED_DR;

    I_ENTERED_CR GL_INTERFACE. TYPE % ENTERED_CR;

    I_ACCOUNTED_DR GL_INTERFACE. TYPE % ACCOUNTED_DR;

    I_ACCOUNTED_CR GL_INTERFACE. TYPE % ACCOUNTED_CR;

    I_TRANSACTION_DATE GL_INTERFACE. TRANSACTION_DATE % TYPE;

    I_REFERENCE1 GL_INTERFACE. REFERENCE1% TYPE;

    I_REFERENCE2 GL_INTERFACE. REFERENCE2% TYPE;

    I_REFERENCE3 GL_INTERFACE. REFERENCE3% TYPE;

    I_REFERENCE4 GL_INTERFACE. REFERENCE4% TYPE;

    I_REFERENCE5 GL_INTERFACE. REFERENCE5% TYPE;

    I_REFERENCE10 GL_INTERFACE. REFERENCE10% TYPE;

    I_GROUP_ID GL_INTERFACE. GROUP_ID % TYPE;

    BEGIN

    Vfile: = UTL_FILE. FOPEN ('CAPEX_ENVIO', 'comas.csv', 'R');

    loop

    UTL_FILE. GET_LINE(Vfile,Cadena,32767);

    dato1: = substr (cadena, instr(cadena, identificador,1,1)-1, instr(cadena, identificador,1,1)-1);

    dato2: = substr (cadena, instr (cadena, identifier, 1, 1) + 1, instr(cadena, identificador,3,1)-3);

    dbms_output.put_line (dato1);

    dbms_output.put_line (dato2);

    -The evidence

    -dbms_output.put_line (cadena);

    -dbms_output.put_line (substr (dato, 3, instr(dato, identificador,1,1)-1));

    -dbms_output.put_line (substr (dato, instr (dato, identifier, 1, 2) + 1, instr(dato, identificador,1,1)-1));

    -dbms_output.put_line (substr (cadena, 1, length (cadena)-1));

    end loop;

    UTL_FILE. FCLOSE (Vfile);

    -----------------------------------------------------------------------------------EXCEPTIONS------------------------------------------------------------------------------------------------------------------------------------------------------------

    EXCEPTION

    When no_data_found then

    dbms_output.put_line ('Todo Correcto');

    When utl_file.invalid_path then

    UTL_FILE. FCLOSE (V_ManejadorFichero);

    RAISE_APPLICATION_ERROR (-20060,'RUTA DEL ARCHIVO NULLIFIED: (');)

    WHEN UTL_FILE. INVALID_OPERATION THEN

    UTL_FILE. FCLOSE (V_ManejadorFichero);

    RAISE_APPLICATION_ERROR ('-20061,'EL ARCHIVO NO PUDO SER ABIERTO ");

    WHEN UTL_FILE. INVALID_FILEHANDLE THEN

    UTL_FILE. FCLOSE (V_ManejadorFichero);

    RAISE_APPLICATION_ERROR (-20062, 'INVALIDO MANAGER');

    WHEN UTL_FILE. WRITE_ERROR THEN

    UTL_FILE. FCLOSE (V_ManejadorFichero);

    RAISE_APPLICATION_ERROR (-20063, 'ESCRITURA ERROR');

    WHEN UTL_FILE. INVALID_MODE THEN

    UTL_FILE. FCLOSE (V_ManejadorFichero);

    RAISE_APPLICATION_ERROR (-20064, 'MODO INVALIDO');

    WHEN UTL_FILE. INTERNAL_ERROR THEN

    UTL_FILE. FCLOSE (V_ManejadorFichero);

    RAISE_APPLICATION_ERROR (-20065, 'ERROR INTERNO');

    WHEN UTL_FILE. READ_ERROR THEN

    UTL_FILE. FCLOSE (V_ManejadorFichero);

    RAISE_APPLICATION_ERROR (-20066, 'LECTURA ERORR');

    WHEN UTL_FILE. FILE_OPEN THEN

    UTL_FILE. FCLOSE (V_ManejadorFichero);

    RAISE_APPLICATION_ERROR ('-20067,'EL ARCHIVO ARE ESTA ABIERTO ");

    WHEN UTL_FILE. THEN ACCESS_DENIED

    UTL_FILE. FCLOSE (V_ManejadorFichero);

    RAISE_APPLICATION_ERROR (-20068, 'REFUSED ACCESS');

    WHEN UTL_FILE. DELETE_FAILED THEN

    UTL_FILE. FCLOSE (V_ManejadorFichero);

    RAISE_APPLICATION_ERROR (-20069, 'OPERACIÓN BORRADO FALLO');

    WHEN UTL_FILE. RENAME_FAILED THEN

    UTL_FILE. FCLOSE (V_ManejadorFichero);

    RAISE_APPLICATION_ERROR (-20070, 'OPERATION SOBREESCRITURA FALLO');

    END;

    Hello

    Try something like this:

    POS1: = INSTR (cadena, idntificador, 1, 1);
    POS2: = INSTR (cadena, idntificador, 1, 2);

    ID: = SUBSTR (cadena, 1, pos1 - 1);
    description1: = SUBSTR (cadena, pos1 + 1, (pos2 - pos1)-1);
    Description2: = SUBSTR (cadena, pos2 + 1);

    where pos1 and pos2 are numbers.

    Rather than use UTL_FILE, consider creating an external table.  You won't have to write any PL/SQL, and this means that you won't be tempted to write a bad article of EXCEPTION.

  • How can I remove text from a PDF file?

    How to clear the text from a pdf file

    Hi iggybuskus2,

    If you want to change the text in a PDF document, you will need to use Acrobat. You can download a free Acrobat www.adobe.com/products/acrobat.htmltrial, if you want to test.

    Best,

    Sara

  • FILLING OUT FORMS FROM A CSV FILE / EXCEL

    I have a form I need to fill all day several times according to the customer, but this information comes from a spreadsheet, I would use a script to fill it up for me, I have enough knowledge to do this script, could someone help me?

    IMAGEM.png

    FORM.png

    I agree with CalosCanto.

    In my humble OPINION more often (by default) CSV are separated by

    T=iText[i].split( ";"); // this is good for SEMICOLON delimited (files) Better in this case: ROWS
    

    - - - - - - - - - - -

    @Ferrarezzi,

    but I think that for your example maybe it could be better prepare your CSV like that:

    If your CSV looks like this, you can do something like this:

    T=iText[i].split( ";");
    //texto=T;
    alert(T[0]+" "+T[1]+"\n"+T[0]+" "+T[2]+"\n"+T[0]+" "+T[3]);
    

    Result:

    Have fun

  • Links of images imported from a CSV file into a SQL table using phpMyAdmin

    I have .csv with five areas, the first is images.

    images150/9310VSony02.jpg.

    This imported into a sql database using phpMyAdmin (first time user) table called rsIMAGESTEST.

    Using Dreamweaver is applying insert for php objects/dynamic Table/Recordset XXX pages

    The table is at - he saw in explores the image url is displayed rather than the jpeg format. image.

    The rest of the data in other areas is fine stright txt. Please can someone explain what I am doing wrong.

    Flowing is the sql I can to get what we need to change?

    @mysql_select_db ($database_pauls, $pauls);

    $query_Recordset3 = SELECT * FROM rsIMAGESTEST;

    $Recordset3 = mysql_query ($query_Recordset3, $pauls) or die (mysql_error ());

    $row_Recordset3 = mysql_fetch_assoc ($Recordset3);

    $totalRows_Recordset3 = mysql_num_rows ($Recordset3);

    To view the image, you must pass the value of the recordset to the src attribute of the tag. Assuming that the domain name is 'image ':

    
    

    You can also use Insert a picture. In the dialog box select the Source Image, the value of "Select file name of" to "Data Sources." You can then select the domain name correct of your recordset.

  • SQLLDR - load only selected columns from a csv file

    Hello

    Can we charge only a few selected columns of a big (INFILE) CSV using SLLDR?

    Thank you in Advcance
    Kapil

    Hello

    You can take a look at this. It may be useful

    DECLARE
    l_start_file_name varchar2(50) := 'invoice_excel_c';
    l_end_file_name varchar2(50)   := '.csv';
    l_file_name varchar2(100);
    l_sql varchar(32767);
    refresh_cdc varchar2(5) := '00304';
    
    begin
    
    l_file_name := l_start_file_name||REFRESH_CDC||l_end_file_name;
    
     l_sql :=
    'create table exter_invoice_excel               '||
    '(                                              '||
    'Product_name                varchar2(255),     '||
    'Net_Sales                   Number,            '||
    'Net_Adjustments             Number,            '||
    'Cancels_Count               Number,            '||
    'Cancels_Amount              Number,            '||
    'Cashes_Count                Number,            '||
    'Cashes_Amount               Number,            '||
    'Claims_Count                Number,            '||
    'Claims_Amount               Number,            '||
    'Returns_Count               Number,            '||
    'Returns_Amount              Number,            '||
    'Free_Prize_Count            Number,            '||
    'Free_Prize_Amount           Number,            '||
    'Free_Promo_Count            Number,            '||
    'Free_Promo_Amount           Number,            '||
    'Promo_Credit_Count          Number,            '||
    'Promo_Credit_Amount         Number,            '||
    'Return_Commission           Number,            '||
    'Net_Discounts               Number,            '||
    'Total_Fees                  Number,            '||
    'Sales_Commission            Number,            '||
    'Cash_Commission             Number,            '||
    'Tkt_Charge                  Number,            '||
    'Subscription_Commission     Number,            '||
    'Interim_Sweeps              Number,            '||
    'Net_Due                     Number,            '||
    'Retailer_id                 Number,            '||
    'Retailer_Name               varchar2(255)      '||
    ')                                              '||
                  'ORGANIZATION EXTERNAL (                 '||
                  ' TYPE oracle_loader                     '||
                   ' DEFAULT DIRECTORY GTECHFILES          '||
                   ' ACCESS PARAMETERS (                   '||
                   '   RECORDS DELIMITED BY NEWLINE        '||
                   '      CHARACTERSET WE8MSWIN1252        '||
                   '   BADFILE ''invoice_excel.bad''       '||
                   '   DISCARDFILE ''invoice_excel.dis''   '||
                   '   LOGFILE ''invoice_excel.log''       '||
                   '   FIELDS TERMINATED BY '','' RTRIM      '||
                   '  MISSING FIELD VALUES ARE NULL        '||
                   '   )                                   '||
                   '   LOCATION ('''||l_file_name||''')    '||
                   ' )                                     '||
                   'PARALLEL                               '||
                   'REJECT LIMIT UNLIMITED ';
    
            execute immediate l_sql;
    
          l_sql:=  'INSERT INTO INVOICE_EXCEL_TEMP                '||
                      ' ( Product_name               ,            '||
                      '  Net_Sales                   ,            '||
                      '  Net_Adjustments             ,            '||
                      '  Cancels_Count               ,            '||
                      '  Cancels_Amount              ,            '||
                      '  Cashes_Count                ,            '||
                      '  Cashes_Amount               ,            '||
                      '  Claims_Count                ,            '||
                      '  Claims_Amount               ,            '||
                      '  Returns_Count               ,            '||
                      '  Returns_Amount              ,            '||
                      '  Free_Prize_Count            ,            '||
                      '  Free_Prize_Amount           ,            '||
                      '  Free_Promo_Count            ,            '||
                      '  Free_Promo_Amount           ,            '||
                      '  Promo_Credit_Count          ,            '||
                      '  Promo_Credit_Amount         ,            '||
                      '  Return_Commission           ,            '||
                      '  Net_Discounts               ,            '||
                      '  Total_Fees                  ,            '||
                      '  Sales_Commission            ,            '||
                      '  Cash_Commission             ,            '||
                      '  Tkt_Charge                  ,            '||
                      '  Subscription_Commission     ,            '||
                      '  Interim_Sweeps              ,            '||
                      '  Net_Due                     ,            '||
                      '  Retailer_id                 ,            '||
                      '  Retailer_Name               ,            '||
                      '  SOURCE                      ,            '||
                      '  INSERTED_DATE               ,            '||
                      '  CDC                         ,            '||
                      '  UPLOADED                                 '||
                      ')                                          '||
    '              select                                         '||
                      '  ltrim(rtrim(product_name)) ,             '||
                      '  Net_Sales                   ,            '||
                      '  Net_Adjustments             ,            '||
                      '  Cancels_Count               ,            '||
                      '  Cancels_Amount              ,            '||
                      '  Cashes_Count                ,            '||
                      '  Cashes_Amount               ,            '||
                      '  Claims_Count                ,            '||
                      '  Claims_Amount               ,            '||
                      '  Returns_Count               ,            '||
                      '  Returns_Amount              ,            '||
                      '  Free_Prize_Count            ,            '||
                      '  Free_Prize_Amount           ,            '||
                      '  Free_Promo_Count            ,            '||
                      '  Free_Promo_Amount           ,            '||
                      '  Promo_Credit_Count          ,            '||
                      '  Promo_Credit_Amount         ,            '||
                      '  Return_Commission           ,            '||
                      '  Net_Discounts               ,            '||
                      '  Total_Fees                  ,            '||
                      '  Sales_Commission            ,            '||
                      '  Cash_Commission             ,            '||
                      '  Tkt_Charge                  ,            '||
                      '  Subscription_Commission     ,            '||
                      '  Interim_Sweeps              ,            '||
                      '  Net_Due                     ,            '||
                      '  Retailer_id                 ,            '||
                      '  Retailer_Name               ,            '||
                      ' '''||l_file_name                           ||''', '||
                      '   sysdate                    ,            '||
                      ' '''||    REFRESH_CDC                       ||''', '||
                      '''N'''                                      ||
                      'FROM                                       '||
                      'exter_invoice_excel                        '||
                      'WHERE retailer_id is not null and ltrim(rtrim(product_name)) in (''Loto'',''Inst Tk'')';
    
            execute immediate l_sql;    
    
            l_sql :='drop table exter_invoice_excel';
            execute immediate l_sql;
    
    exception
    when others then
    rollback;
    l_sql :='drop table exter_invoice_excel';
    execute immediate l_sql;
    debug_message('INVOICE_EXCEL_UPLOAD/'||REFRESH_CDC,'Unexpected Error '||sqlerrm);
    END;
    
    --truncate table invoice_excel_temp
    

    Thank you

Maybe you are looking for

  • Flight Simulator: Fs 2004 (FS9) disk #4 will not install on XP pro.

    First three discs load faster. Rear disc load slow and stops at 77% on the bar of load with this error message: "disk error;@scenery/cities/amsterd Encounted. ACR; Make sure disk is not full, and that the file is not in use. "I've got a Dell Dim E520

  • I don't have Skype or Silverlight on this computer. Can I use Skype?

    Original title: Windows 7 or Windows XP? Helllo everyone... I need some info, I use my Windows XP and somehow I am signed in and on this site. I don't have Skype or Silverlight on this computer. Can I use Skype?  Should I just get on the phone and se

  • Acer Aspire E5-571 Acer Care Center

    Hello. I can't download Acer Care Center for a reason any. I tried via Wi - Fi connectivity and with no joy. Guests AcerCareCenterCheckTool download has failed. Please check your network connection and try again. I tried to run as administrator, trou

  • window problem

    I managed to remove the bar that displays back and back arrows it, the option file and history, bookmark, etc..., how do I put back up there

  • ThinkPad Helix - HDMI?

    Does anyone know if the Thinkpad propeller will have an HDMI port of micro/mini on the tablet or the keyboard?  Other sites say it has a mini HDMI port and Lenovo Web site has no mention.  I know, from the Lenovo Web site, it has a minidisplay port.