Forum Stats

  • 3,838,860 Users
  • 2,262,407 Discussions
  • 7,900,772 Comments

Discussions

Importing single quotation mark + scripting

v.nones
v.nones Member Posts: 11
edited Jun 18, 2015 5:05AM in Financial Data Management

Hi everyone

I am using FDMEE 11.2.3Hi have in my data several fields and one is ...,XXX'XXX,....,2000

I am not even mapping the XXX'XXX value but it seems that I cannot load the data since is trying to convert a non-numeric value into a number and I don't understand why.

I tried to solve this with a BefImport script trying to replace the ' character without being successful. I don't know also what it is wrong in my syntax.

if fdmContext["LOCNAME"] == "YYY":

     fdmAPI.logInfo(fdmContext["LOCNAME"])

     try:

          filename = fdmContext["FILENAME"]

          inbox = fdmContext["INBOXDIR"]

          fdmAPI.logInfo(filename)

          fdmAPI.logInfo(inbox)

          file = inbox + "\\YYY\\" + filename

          file_out = inbox + "\\YYY\\" + filename + ".out"

          fdmAPI.logInfo(file)

          fin = open(file,"r")

          fout = open(file_out,"w")

          for line in fin:

               lineIni=line.replace(''','_')

               fout.write(lineIni)

          fin.close()

          fout.close()

     except IOError, err:

         fdmAPI.logError("My error"+ str(err))

     os.remove(file)

     os.rename(file_out,file)

Does anybody has some insights on this?, why is it taking ' as a comma?

Thank you and regards.

Tagged:

Best Answer

  • v.nones
    v.nones Member Posts: 11
    edited Jun 18, 2015 5:05AM Answer ✓

    Hi,

    Yes I copied the script from the solution and transform it. Now I have finished digging into it and apparently a single quotation mark ' is a wildcard so it is solf putting this \ in the script  before the quotation mark as it follows (maybe it will be useful to someone else):


    if fdmContext["LOCNAME"] == "DSLWGLMulti":
         fdmAPI.logInfo(fdmContext["LOCNAME"])
         try:
              filename = fdmContext["FILENAME"]
              inbox = fdmContext["INBOXDIR"]
              #filedir = fdmContext["FILEDIR"]
              fdmAPI.logInfo(filename)
              fdmAPI.logInfo(inbox)
              file = inbox + "\\DSLWGLMulti\\" + filename
              file_out = inbox + "\\DSLWGLMulti\\" + filename + ".out"
              #file = inbox + "\\" + filedir + "\\"+filename
              #file_out = inbox + "\\" + filedir + "\\"+filename + ".out"
              fdmAPI.logInfo(file)
              fin = open(file,"r")
              fout = open(file_out,"w")
              for line in fin:
                   line = line.replace('\'','')
                   fout.write(line)
              fin.close()
              fout.close()
         except IOError, err:
             fdmAPI.logError("My error"+ str(err))

         os.remove(file)
         os.rename(file_out,file)

Answers

  • SH_INT
    SH_INT Member Posts: 3,192 Bronze Crown
    edited Jun 17, 2015 4:41AM

    I don't think it is treating the apostrophe as a comma but it is not being treated as a string literal which is probably messing up the parsing of the input. You are on the right lines trying to alter the content before import. If you wanted to keep the apostrophe you should replace it with 2 apostrophes or if not replace with another character like the underscore in your script. On first view your script looks ok what is actually the issue with the output i.e. is it producing a new file but not modifying it as you would wish or failing earlier than that?

  • Francisco Amores
    Francisco Amores Member Posts: 1,694 Bronze Crown
    edited Jun 17, 2015 7:35PM

    Hi,

    Are you in 11.1.2.3.530?

    issue with apostrophes is solved in 530.

    fishing with FDMEE

    v.nones
  • v.nones
    v.nones Member Posts: 11
    edited Jun 18, 2015 5:05AM Answer ✓

    Hi,

    Yes I copied the script from the solution and transform it. Now I have finished digging into it and apparently a single quotation mark ' is a wildcard so it is solf putting this \ in the script  before the quotation mark as it follows (maybe it will be useful to someone else):


    if fdmContext["LOCNAME"] == "DSLWGLMulti":
         fdmAPI.logInfo(fdmContext["LOCNAME"])
         try:
              filename = fdmContext["FILENAME"]
              inbox = fdmContext["INBOXDIR"]
              #filedir = fdmContext["FILEDIR"]
              fdmAPI.logInfo(filename)
              fdmAPI.logInfo(inbox)
              file = inbox + "\\DSLWGLMulti\\" + filename
              file_out = inbox + "\\DSLWGLMulti\\" + filename + ".out"
              #file = inbox + "\\" + filedir + "\\"+filename
              #file_out = inbox + "\\" + filedir + "\\"+filename + ".out"
              fdmAPI.logInfo(file)
              fin = open(file,"r")
              fout = open(file_out,"w")
              for line in fin:
                   line = line.replace('\'','')
                   fout.write(line)
              fin.close()
              fout.close()
         except IOError, err:
             fdmAPI.logError("My error"+ str(err))

         os.remove(file)
         os.rename(file_out,file)

This discussion has been closed.