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

Tags: Database

Similar Questions

  • 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

  • Problem loading of a large number of csv files

    Hi all

    I have a problem loading of a large number of csv files in my LabVIEW program. I have attached a png image of the code simplified for only loading sequence.

    What I want to do is load the data of 5000 laser beam profiles, so 5000 files csv (68 x 68 elements), and then proceed to an analysis of data. However, the program will only ever 2117 files, and I get no error message. I also, tried at the beginning of loading a single file, selecting an area of cultures - say 30 x 30 items - and then to load the rest of the files cropped to these dimensions, but I always get only 2117 files.

    Any thoughts would be appreciated,

    Kevin


  • Error loading of the data in the .csv file

    Hello

    I get error of date below when loading data through Olap tables through .csv file.

    Data stored in .csv is 20071113121100.

    "
    TRANSF_1_1_1 > CMN_1761 Timestamp event: [Mon Mar 29 15:06:17 2010]
    TRANSF_1_1_1 > TE_7007 evaluation of processing error [< < Expression error > > [TO_DATE]: an invalid string for the conversion to date]
    [... t:TO_DATE(u:'2.00711E+13',u:'YYYYMMDDHH24MISS')]
    TRANSF_1_1_1 > CMN_1761 Timestamp event: [Mon Mar 29 15:06:17 2010]
    TRANSF_1_1_1 > TT_11132 Transformation [Exp_FILE_CHNL_TYPE] was a mistake in assessing the output column [CREATED_ON_DT_OUT]. Error message is [< < Expression error > > [TO_DATE]: an invalid string for the conversion to date]
    [.. t:TO_DATE(u:'2.00711E+13',u:'YYYYMMDDHH24MISS')].

    TRANSF_1_1_1 > CMN_1761 Timestamp event: [Mon Mar 29 15:06:17 2010]
    TRANSF_1_1_1 > TT_11019 there is an error in the [CREATED_ON_DT_OUT] port: the default value for the port is on: ERROR (< < Expression error > > [ERROR]: error processing)
    ... nl:ERROR(u:'transformation_error')).
    TRANSF_1_1_1 > CMN_1761 Timestamp event: [Mon Mar 29 15:06:17 2010]
    TRANSF_1_1_1 > TT_11021 an error occurred to transfer data from the Exp_FILE_CHNL_TYPE transformation: towards the transformation of W_CHNL_TYPE_DS.
    TRANSF_1_1_1 > CMN_1761 Timestamp event: [Mon Mar 29 15:06:17 2010]
    TRANSF_1_1_1 > CMN_1086 Exp_FILE_CHNL_TYPE: number of errors exceeded the threshold [1].
    "

    Any help is greatly appreciated.

    Thank you
    Poojak

    What tool to spool the file well? Did he go any where near a GUI tool? I bet it was the precision on the data type or the type of incorrect data in total

    If I paste 20071113121100 into a new excel workbook, the display will return as 2.00711E + 13 - when I put a column data type number that I see all the numbers.
    OK it's not great, but you get what im saying:
    Can run the SQL SQL of plu and coil directly to the file?

  • 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}

  • 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

  • There is a special token that I can put in a column of the CSV file recovery channel which implies approval of the current value?

    Versistand version is 2013 sp1.

    I use stimulus CSV expressions in my sequence in real time and want a channel to keep its value current (last) until a certain time. Is there a way to do this?

    Stimulation CSV file example:

    timestamp, chan1, chan2

    0,0,

    10, 1,

    20,1,5

    30,2,10

    In this example, chan2 would retain its current value until the timestamp 20.

    Is it possible to implement this feature?

    Kind regards

    Rick Howard

    Thank you! It is a valuable feedback. I can't think of a way to do natively with the functionality of reading CSV for sequences in real time. Some thoughts on how this can be done:

    1. create your own utility to sequences of script based on a CSV file in real-time. Extend the functionality of having a special marker in a cell which designates not only to change the value for the channel as timestep. Do not start from scratch. This tool open source and this one the two script of sequences in real time and stimulation of reading profiles based on data sets (although in different ways).

    2. with the help of software without insertion to the fault of the string value that you want to keep the initial value for the first X seconds of reading the CSV file. For example, you could play another sequence with your CSV file at fault the channel at its current value so that reading CSV does not replace the value.

  • 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

  • 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.

  • 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

  • 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
    
  • Load a picture 2D from a txt file

    Hi, I have a little problem on the table: /.

    I'm a little game of tiles according to the coding, and I load the map from a .txt file.

    The txt file is like this:

    0 1 0 1 0 1 0 0 0 0 0 1 1 1 1

    1 0 1 0 1 0 0 1 1 0 1 0 1 0 1

    ...

    and I want to just use it in this loop:

    for (var i: int = 0; i < mapHeight; i ++)

    {

    for (var j: int = 0; j < mapWidth; j ++)

    {

    var cell: MovieClip = new tile();

    cell.gotoAndStop (map [i] [j] + 1);

    If (i % 2 == 1) {}

    Cell.x = 70 * j - 35;

    Cell.y = 35 * i;

    }

    else {}

    Cell.x = 70 * j;

    Cell.y = 35 * i;

    }

    addChild (cell);

    }

    }

    This loop works if I create the table on the map in the AS3 file, but with 10 cards, the code will be very very very long.

    I tried to load the table from a txt file, but there is not a lof on internet information and I'm stuck.

    To load the txt file:

    var mapLoader:URLLoader = new URLLoader();

    mapLoader.addEventListener (Event.COMPLETE, onLoaded);

    function onLoaded(e:Event):void {}

    var maptext:String = e.target.data;

    var map: Array = maptext.split("");

    trace (Map);

    }

    mapLoader.load (new URLRequest ("map1.txt"));

    But I do not understand how to use 'map' after that, I can't use it in the loop to add cell, I have an error.

    I find that all it really complicated to load just a simple table 2D from a txt file.

    Can't I just put all the maps in AS3 in a different txt file and load this part of code when I need it? Like this:

    "var map: Array = [];

    [1,0,0,1],

    [1,1,1,1]

    [0,0,0,0]

    [0,1,0,1],

    ]; "

    Thanks for the help and sorry for the bad English.

    If I recreate the first version, I get the same result as what you show for the second version - I do not get the result snapped up as show you.  My guess is that you have the data file prepared incorrectly when you organize the data into it.

  • Delete the name of the column in the CSV file generated by ODI

    Hello

    I want to remove the column names in the CSV file that I create the database.
    I tried to put "towards zero in the data store ', that I created for the csv file, but it does not work.

    Please help.

    Thank you
    Sudeep Nathalie

    Sudeep salvation,

    Ok.. If you don't want the column to be generated and then in your IKM (IKM SQL to THE grit file) choose the option GENERATE_HEADER to 'no '.

    Then run the interface. The target csv file will not now column header.

    Thank you
    Fati

  • 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:

  • 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

    }

Maybe you are looking for