Using .split on an import script with a comma delimited data file

Hi everyone-

Any attempt to create a script to import amount field to remove the apostrophes (') of a description field to account in a .csv data import file (any folder with an apostrophe will be rejected during the import phase).  Now if it was a file delimited by semicolons (or other separators and more by commas), I could remove all the apostrophes recording with a string.replace command, then return the amount with a command of string.split.  Unfortunately, there is a problem with this solution when using comma delimiters. My data file is comma-delimited .csv file with several amount fields that have commas in them.   Even if the fields are surrounded in quotes, the .split ignores the quotes and treats the commas in fields amount as delimiters.  Therefore, the script does not return the correct amount field.

Here is an example of a record of reference data:

"", "0300-100000", "description of the account with an apostrophe ' ', '$1 000.00",' $1 000.00 "," $1 000.00 ","$1 000.00"," $1 000,00 "" "

My goal is to remove the apostrophes from field 3 and return the amount in field 8.

Some things to note:

  • If possible, I would like to keep this as an import script for amounted to simplify administration - but am willing to undertake the event script BefImport if this is the only option or more frank than the import script-based solution.
  • I tried using regular expressions, as seems to be conceptually the simplest option to respect the quotes as escape character, but think that I am not implementing properly and impossible to find examples of regex for FDMEE.
  • I know that we cannot use the jython csv on import the script by Francisco blog post - fishing with FDMEE: import scripts do not use the same version of Jython as event/Custom scripts (PSU510). This may be a factor to go with a script of the event instead.
  • It's probably a little more engineering solution, but I have considered trying to write a script to determine where to start all the quotes and the end.  Assuming that there are no quotation marks on the inside of my description of account (or I could remove them before that), I could then use the positioning of the quotes to remove commas inside those positions - leaving the commas for the delimiters as is.  I could then use the .split as the description/amount fields have no commas.  I think it may be better to create a script of the event rather than down this solution from the point of view to keep administration as simple as possible
  • Yes, we could do a search and replace in the excel file to remove the apostrophes before import, but it's no fun

Thanks for any advice or input!

Dan

Hi Dan,.

If your line is delimited by comma and quote qualified, you can consider the delimiter as QuoteCommaQuote or ', ' because it comes between each field.  Think about it like that, then simply divided by this value:

split("\",\"")

Here's something I put together in Eclipse:

'''

Created on Aug 26, 2014

@author: robb salzmann

'''

import re

strRecord = "\"\",\"0300-100000\",\"Account description with an apostrophe ' \",\"$1,000.00\",\"$1,000.00\",\"$1,000.00\",\"$1,001.00\",\"$1,002.00\""

strFields = strRecord.split("\",\"")

strDescriptionWithoutApos =  strFields[2].replace("'", "")   'remove the apostrophe

strAmountInLastCol = strFields[-1:].replace("\"", "")        'You'll need to strip off the last quote from the last field

print strDescriptionWithoutApos

print strAmountInLastCol

Account with an apostrophe description

' $1 002,00

Tags: Business Intelligence

Similar Questions

  • can I use waiting fuction in java script with qml

    HII guyzz... How to use the wait in java script with QML function as if it takes 20 minutes to perform a specific operation or a process after that battery is 100%

    You are better off using QTimer for something like that.

  • How to use parallelism in the RMAN script with multiple lines

    Gurus,

    Need your advice on the use of parallelism in the script "BACKUP AS COPY DATAFILE" have several lines.

    I have a script like below:

    SET UP THE DEVICE TYPE DISK PARALLELISM 10;
    backup copy datafile ' / data1/oradata/PROD/data01.dbf' size '+ DATA ';
    backup copy datafile ' / data2/oradata/PROD/data02.dbf' size '+ DATA ';
    backup copy datafile ' / data3/oradata/PROD/data03.dbf' size '+ DATA ';
    backup copy datafile ' / data4/oradata/PROD/data04.dbf' size '+ DATA '; and so on...

    If I run this script, it runs in the order. How do I in parallel can I copy data files required?
    I selectively copy a few files in ASM.
    I want to use a single script.

    Please notify.
    Best regards
    David

    Published by: 966454 on October 18, 2012 23:59

    Published by: 966454 on October 18, 2012 23:59

    Try to use only a backup statement with the manual channels and parallelism configured as stated in my previous message. For example:

    CONFIGURE DEVICE TYPE DISK PARALLELISM 3;
    CONFIGURE DEFAULT DEVICE TYPE TO DISK;
    CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '+DATA1/%U';
    CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '+DATA2/%U';
    CONFIGURE CHANNEL 3 DEVICE TYPE DISK FORMAT '+DATA3/%U';
    BACKUP AS COPY DATAFILE 4,5,6;
    
  • can we use 32-bit components (ODAC) Oracle with oracle 64-bit data access

    Hi all


    Let me know for oracle 11G 64 bit the latest patches are available?

    Yet more can we use 32-bit components of Oracle (ODAC) with oracle 64-bit data access.


    Thank you
    Fadi

    Let me know for oracle 11G 64 bit the latest patches are available?

    Check on http://metalink.oracle.com

    Yet more can we use 32-bit components of Oracle (ODAC) with oracle 64-bit data access.

    I guess you mean to use 32-bit components ODAC on the client side. I've not seen this in practice, but it should be possible as long as we do not / cannot upgrade all clients to 64-bit.

  • retrieve the information of partition table with lack of offline data file

    I just restored a backup of a database. When I unzipped data files, I discovered that a single data file was so damaged in the starting order of the database, I had to put the offline data file. The tablespace which reports the data file holds the information of partition of a table. Since I have no archives from when the data file has been created, I know it is not possible to recover the data file, I have to recover as many lines as possible other files in the tablespace data but when export or create the table as what to choose in the affected partition get ORA-00376 : cannot read file 1624 at the moment.

    is there a way to tell oracle to ignore the data offline file and export the remaining data file information?

    Just to clarify my situation a little more;
    iI have a table called PPGA_ACTABOPRE that is partitioned by HASH and has 20 partitions, each partition in a different tablespace and tablespace each have about 8 files of data. A data file in the partition 9 is missing and I want is to get the information from the files of the remaining data, but whenever I issue a select statement or an exp or anything I get ORA-00376.

    I try to set the flag to ignore blocks corrupt with run DBMS_REPAIR. SKIP_CORRUPT_BLOCKS ('PPGA', 'PPGA_ACTABOPRE'); and then select the info but it did not work.

    Any suggestion would be appreciated;
    Thanks in advance

    For the actabopre_p08 partition, some files are available, and we're not. You can access data at the segment level, because some extensions are missing.

    You would need to access the data by rowid. You could loop through dba_extents and use dbms_rowid.create to generate a list of ROWID that may exist in the available data files.

    This may help: -.

    http://kerryosborne.Oracle-guy.com/2009/02/saving-rows-from-corrupt-blocks/
    http://kerryosborne.Oracle-guy.com/scripts/save_u.SQL

    Published by: Robert Geier on March 12, 2010 15:33

  • Is it possible to recover a database with the copy of data files (cp), while the database has been opened?

    Hello

    We know we need to do a backup of an oracle database by using the appropriate tool, in most cases the rman. But we have in our society, a person who helps us with the backup of all the databases oracle we have. Thus, in addition to the rman backups, we do a copy (cp) with the open database of all files in oracle database, (without start backup) including of course spfile, controlfile, etc.. My question is: can recover us my database using this copied data files? or are we just wasting disk space on our backup environment?

    Kind regards
    Melo.

    We're doing a copy (cp) with the open database of all files in oracle database, (without start backup) including of course spfile, controlfile, etc..

    As EdStevens said, it's essentially a backup without value. When you copy files from a backup ' hot', there may be inconsistencies in the blocks of the file as transactions actively edit these blocks while the copy is made. Mechanism of Oracle backups hot managed by users is to put the database or tablespace in backup mode, copy the files, and then the end backup mode. Without this mechanism, the chances of being able to restore from this backup are very, very thin.

    My question is: can recover us my database using this copied data files?

    My question is... have you tested recovery? If the recovery has been piloted, then called the answer to this question. Please read the end of this blog post for more information:

    Blog of Peasland before necessary recovery database backups"

    See you soon,.
    Brian

  • Using the channel of the flaws with the reading of data

    Is it possible to substitute a model output when I want real data playback using the stim profile editor?

    I understand how to use the flaws of the stim profile editor to replace an unique to a single value output channel, but is there a way to "fault" of the channel to the data I read (.csv file)?

    Don't know how I missed that...  Exactly what I was looking for.

    Thank you
    Matt

  • I used to be able to do with discs DVD-R data discs, now iv changed my hard drive and my computer only recognizes CD - R when I try to burn data?

    "Please insert the disk" error message when I try to burn data to DVD-R disc but works fine when burning data on CD - R.  Also, he can't read and data DVD - R disks, I made from the same computer in the past with the old hard drive, is my new hard drive, missing some sort of driver or something?  Windows XP computer bought from Dell about 4-5 years (Dell 5150).  He let me play commercial CD, burn CDs and burn data on CD - r.  He no longer do anything with a DVD-R disc, wont even recognize one, please help

    Hi malikchebli,

    See the below Microsoft article and try the steps mentioned, check if it helps.

    How to troubleshoot common problems that occur when a Windows XP-based computer cannot read a CD or DVD

    http://support.Microsoft.com/kb/321641

  • Error using DW import script. Utilities.fParseString: Type mismatch: 'CLng.

    Is it possible to use CLng FDM import Scripts to convert a String data type to a Long data type, so that it can be evaluated numerically? Currently, I get the following error:

    Error:
    "Error: an error occurred importing the file."
    Detail: Type mismatch: 'CLng.
    Online: 13 "


    Script:
    Function TBNetwork (strField, strRecord)

    Dim Inga
    Inga = CLng (DW. Utilities.fParseString (strRecord, 8, 3, ","))

    If Inga > 62100 then
    TBNetwork = "Greater".
    On the other
    TBNetwork = "lower to."
    End If

    End Function


    CSV data file:
    Field1, Field2, Field3, Field4 sphere5, case Field6, Field7, Field8
    101, B1000, 62100, L0000, 401, C00001, IY002, '-10,000,000.00.
    101, B1000, 62100, L0000, 401, C00002, IY003, '-6,646,939.00 '.
    101, B1000, 62100, L0000, 401, C00003, IY004, '-55,100,000.00 '.

    Published by: Jubei on May 4, 2012 15:02

    What is the header line?

    Try

    Function TBNetwork (strField, strRecord)

    Dim Inga
    Inga = DW. Utilities.fParseString (strRecord, 8, 3, ',')

    If IsNumeric (Inga) then
    If CLng (Inga) > 62100 then
    TBNetwork = "Greater".
    On the other
    TBNetwork = "lower to."
    End If
    On the other
    RES. PblnSkip = True
    End If
    End Function

  • Use of Variables in a Script of Essbase report

    I know you can use a variable in a script with Essbase report & at the beginning of the name.  Example & CurMonth.  This works very well for me.  But, you can use & FcstMonths when the value of the months are more than one Member?  It works in a calc script when & FcstMonths = March, April, may, June... etc, but, when I use it in a report script, the script will not validate the saying "unknown member of the value.  I tried to change it to January.February.March... etc.  I also tried February: December.  None of them does not seem to work.  Is it just not possible for Essbase report?  Thanks in advance.

    If you want to include a list of members in the report script, you specify the members separated by spaces.  If you set the variable...

    "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"
    

    ... I think you'll find that it works.

  • Import script API

    Hi guys,.

    Here's my question! If we know, we CN can't use API in the import scripts, is possible to use the API in the import scripts? :)

    Without using the API in the import scripts, how can you call a script in another script or in the same script? (using functions such as fImportScripts, etc.)

    Thank you in advance!

    I have no problem understanding of your question. However the sentence key in my answer was that you'll get better answers if you ask specific questions. The reason why I ask you to be specific, it's I know WHY you want to use the API in a script to import, I might be able to make suggestions how to solve for your needs by going in a different way.

    I want to help you, but I need something concrete to go.

    On the issue of the API, you ask:

    Well, I guess the general answer is no. The purpose of the API is out of context when executing an import script. I imagine that this prevents users to code something when you import that would cause FDM to tangle itself by allowing direct access to the data and runtime objects. Whatever the reason, it's the way THAT FDM is designed, and you need the code within this design in order to get help. It is a long journey around the same answer I gave you earlier.

    However, the second part of your question, can call you other scripts of the import script: Yes, absolutely. You can start the process too.

    Kind regards
    Robb Salzman

  • ORA-01124: cannot retrieve the data file 1 - file is in use or recovery

    I'm trying to recover the database in waiting, but it gives the error below.

    ORA-00283: cool cancelled due to errors
    ORA-01124: cannot retrieve the data file 1 - file is in use or recovery, the recovery is already said
    ORA-01110: data file 1: ' I:\ORACLE\QAS\SAPDATA1\SYSTEM_1\SYSTEM. DATA1'

    When I checked in the alert log recovery is not started. and later I hae given ' alter database recover Cancel "and the command to meet with the threshold.

    "media recovery has not started.

    It seems that the recovery was stuck between the two.
    Please advise me how to kill the recovery session that is stuck. because I don't want to bounce the database pending.

    Thanks in advance.

    Dataguard and MRP, you run a script before.

    In a standby scripted, a session to RETRIEVE the DATABASE would an UNTIL clause (SEQUENCE up to THAT most likely). At the end of the recovery at this point (SEQUENCE #), he left and stop at the database.

    In addition, the script is such that when a RECOVERY session is active, another session is not authorized to start. It can loop in pending state or go out and do it again the next scheduled interval.

    Apparently your startup script is not strong enough to prevent another session of RECOVERY to start even though the first is active (or it doesn't have a good up to THAT clause and stop, exit, closing stocks)

    What you have is a custom implementation of a database of pending. Without all the details of the script, the 'blocking' between sessions (to avoid a second RECOVER start when one is already running) etc... We can't really do much to help you.
    Your scripts must be standing with status information. It should be possible for you to discover the 'other' sqlplus session which emanates a DATABASE to RECOVER, but not yet out (p. ex... How about a simple "ps - ef |") grep sql' and ' ps - ef | combination of grep ora"?)

    Hemant K Collette

    Published by: Hemant K Collette on May 29, 2013 17:47

  • Problems with duplicate DATA when the data file was added after the backup completes

    Hello

    I am facing a problem when running of duplicate database with the command of database duplicate RMAN on a 10 g database. If I have the duplication from a full backup that is missing a data file that has been added to the database after the full backup of preforms, I get the following error message:
    Starting restore at 10-10-2009 18:00:38
    
    released channel: t1
    released channel: t2
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of Duplicate Db command at 10/10/2009 18:00:39
    RMAN-03015: error occurred in stored script Memory Script
    RMAN-06026: some targets not found - aborting restore
    RMAN-06100: no channel to restore a backup or copy of datafile 43
    Redo log which was Pond at the time of the creation of 43 of the data file is also available in the backups. It seems that RMAN cannot use the log information archived redo to restore the content of the data file 43. I guess that because failure is already reported in the RESTORATION and not in the RECOVERY phase, so again the archived logs are not available yet. I get the same message even if I do another backup of the data file 43 (so a backup that is not in the same backupset as the backup to all the other data files).
    The script, the command duplicate product, I guess that RMAN reads the contents of the source database controlfile and trying to get a backup that contains all the data files to restore the database Assistant - if such a backup is not found, it fails.


    Of course, if I try to perform a restore/recovery of the source database, it works without problem:
    RMAN> restore database;
    
    Starting restore at 13.10.09
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: sid=156 devtype=DISK
    
    creating datafile fno=43 name=F:\ORA10\ORADATA\SOVDEV\SOMEDATAFILE01.DBF
    channel ORA_DISK_1: starting datafile backupset restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    restoring datafile 00001 to F:\ORA10\ORADATA\SOVDEV\SYSTEM01.DBF
    .....
    The 43 data file is re-created and then redo is applied to the course.

    So, does anyone know if the duplicate database can use archived redo logs to recreate the contents of a data file, as does a normal restore/recovery? If this is the case, then it is necessary to perform a full backup before each duplicated if a data file has been added after such a backup database.

    Thanks in advance for any answers.

    Kind regards
    Swear

    Hi swear,.

    I got exactly the same problem during replication.
    Because we backup archive logs every 6 hours with rman, I added an additional block of running this script.
    run
    {
    backup incremental level 0
    format "% d_ % s_ %%t p_ bk_ '.
    filesperset 4
    database not saved;
    }

    (I also hit a bug in the catalogue which was resolved by patching up the dbs catalog 11.1.0.6, 11.1.0.7 for.)

    This will restrict the data not making file not part of any backup rman 6 hours while jumping for which there is already a backup of data files.

    Kind regards

    Tycho

  • Tablespace with a data file name in double and the directory added

    Version Oracle 11.1.0.7
    AIX platform

    I have exactly the same directory for the tablespace even a tablespace with 2 files with exactly the same name.

    I don't think it was possible for Oracle create two data files in the same directory with exactly the same data file for a tablespace name.

    The difference between the two seems to be the sizes - one is 10G, the other is 10 m autoextend on but with maximum size is equal to the size of create.

    It is not possible to table either both are full.

    Please notify.

    Thank you.

    You have a character that is hidden in the name of the file. Use ls for your operating system which shows the special characters (ls - lb or something, man ls).

  • Use of a single tablespace or backup data file

    Hello

    I read the RMAN manual and I'm quite familiar with backup a tablespace or data file, but I can find very little uses for it. Backup upward a tablespace is useful for the TPITR, but since who needs another instance sound very little useful in most production environments. I think that you cannot restore an older version of tablespace in a normal database, except if the tablespace has been done long read-only, in which case RMAN optimizations will do the trick.
    Still less use that I can find for the backup of the data file. I have absolutely no idea of what you can do with a single data file.

    Can you please tell me about the uses of these RMAN features?

    Thank you.

    Hi again!

    OK, you're right. If you are using noarchivelog moden then a partial database backup is no useful. Only the archivelogmode can make a useful partial backup of DB.

    Best regards

    Florian W.

Maybe you are looking for

  • Slate 7 impossible to insert the sandisk ultra 32 GB micro sd class10

    I bought a sandisk ultra 32 GB micro SD class 10 SKU SDSDQU - 032 G-CFAP-out of amazon. When I insert in my 7 slate and push on to try to get to the spring to engage and the drive to go it is not. I can't get the SD card to stay in and I feel a sprin

  • Portege M800 - HD upgrade internal?

    Hello I'm new here... Is it possible to move to a larger internal hard drive for PC Portege Tablet? I have 120 GB and it is almost full and I have seen Western Digital Scorpio 250 GB sata300 and also Toshiba MK3252GSX 320 GB... Everything good? Possi

  • Overscan disabled when using an HDMI cable

    Then for a while now, I use my laptop computer while it is plugged into my TV. But the parts of the screen are cut (top, left, right and bottom, which makes no sense since there is no reason to cut the sides) I've seen guides tell you how to disable

  • Replacing the fan Pavilion dv6

    Hello! I found the manual for my computer but I am not sure how deturmine if he has a discrete or UMA memory in order to order the part to replace the fan. The fan in the summer in place for some time, leading to overheating of the issues and has now

  • Computer restarts on own guard

    I have my Dell 1525 laptop has Vista on it. I have all the software up to date. My computer guard stop and restarting on its own. When I log in again-it will say the computer shut down incorrectly and windows will tell me if there is a solution for t