Forum Stats

  • 3,871,979 Users
  • 2,266,360 Discussions
  • 7,911,017 Comments

Discussions

Data sync error due to custom before import script

User_7W4RM
User_7W4RM Member Posts: 12 Green Ribbon
edited Mar 3, 2020 8:19AM in Financial Data Management

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)

Best Answer

Answers