Skip to Main Content

Analytics Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Data sync error due to custom before import script

User_7W4RMFeb 24 2020 — edited Mar 3 2020

Hi Experts,

I have an issue while trying to use data sync functionality to copy data from one application to another.

Issue seems to generate due to a custom "before import" script which checks POV period with file period.

Can i change the script below so that it does not runs for data sync location/ for specific data load rule?

#----------------------------------------------------------------------
# Import section
#----------------------------------------------------------------------

from codecs import open
from os import path

#----------------------------------------------------------------------
# Context
#----------------------------------------------------------------------  

fileName = fdmContext["FILENAME"]
locName = fdmContext["LOCNAME"]
inboxDir = fdmContext["INBOXDIR"]
periodKey = str(fdmContext["PERIODKEY"])

#----------------------------------------------------------------------
# Constant section
#----------------------------------------------------------------------
POVMarker = "Year to date as of "

dictPOVMarker = {
                "Argentina": "PERIOD :"
                }

#----------------------------------------------------------------------
# Event script code
#----------------------------------------------------------------------  

# open source file and read header
msg = ""

if fileName.find(".xls") < 0:
    filePath = path.join(inboxDir, locName, fileName)
    try:
        oFile = open(filePath, "r")
        fdmAPI.logDebug("File %s opened" %(filePath))
    except:
        fdmAPI.logInfo("Error opening file %s" %(filePath))

    line = oFile.readline().strip()

# get details from POV
        # sample line looks like Year to date as of 08-2018'
        POVMarker = dictPOVMarker.get(locName, POVMarker)
        position = line.find(POVMarker) + len(POVMarker)
        if line.find(POVMarker) >= 0:
            periodFile = line[position:position + 2]
            yearFile = line[position + 3 :position + 7]
        else:
            errMsg = "File does not contain POV Marker"
            fdmAPI.showCustomMessage(errMsg)

This post has been answered by user6692921 on Feb 24 2020
Jump to Answer

Comments

Gaz in Oz

You could use XMLQUERY()

Paulzip
Answer

I could easily do this for you, but you won't learn anything.  However, here's a good article on how to go about it.

Marked as Answer by muttleychess · Sep 27 2020
muttleychess

wonderful !!

It seems the same example

Only I would like to know how to get the version of XML

xml version="1.0" encoding="UTF-8" standalone="yes

mNem

something like ...

select 

'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'

||

xmlserialize(document ... as clob indent) as xml_output

....

Paulzip

muttleychess wrote:

wonderful !!

It seems the same example

Only I would like to know how to get the version of XML

xml version="1.0" encoding="UTF-8" standalone="yes

The prolog is added (and only needed) if you serialise the data to a BLOB.  It's simply for the consumer's sake so they know how to decode the BLOB into character data.  If you are serialising into a CLOB, you don't need it, however if you really want to, use mNem's concat approach.

report error:
Oops, something went wrong!  We've notified our team to take a look. Please try again later. (Reference 300000.25.201.31548).