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!

Covert excel to flatfile and upload the flatfile in data load rule by Jython

H_WwNov 2 2016 — edited Jan 9 2017

Hi All,

Recently I have a requirement as below: I want the users upload the excel file and when they execute the data loading process, they trigger the BefImport event script and the script should convert the excel file to txt and import the txt file instead of the excel file.

What I have now is I am now able to use python to open an excel file on local -> read all the content -> copy all the data to a flat file and save it on local.Unfortunately my code below does not work this way.

However, I stuck at the file uploading and file reading parts on FDMEE.

1.How can I save the txt file to FDMEE server as the FDMEE only can import data that on its own server?

2.If the txt file is saved to FDMEE server successfully, how can I let the Data load rule use this txt to replace the xls file?

xlsx.jpg/servlet/JiveServlet/downloadImage/2-14094200-251776/xlsx.jpg

------Code starts here--------

import xlrd

workbook=xlrd.open_workbook("fdmContext["INBOXDIR"]"+"/ExcelFormatConvertTest.xlsx")

sh=workbook.sheet_by_name("Sheet1")

print sh.nrows

print sh.ncols

r=0

c=0

file=open("fdmContext["INBOXDIR"]"+"/ExcelFormatConverTest.txt","w")

for r in range(sh.nrows):

for c in range(sh.ncols):

    data =sh.cell\_value(r,c)+" "

    print  data,

    file.write(data+" ")

print

file.write("\\n")

file.close()

------Code Ends here--------

Error log:

ErrorMsg.jpg

Any idea or suggestion will be appreciate!

Thanks

This post has been answered by SH_INT on Nov 2 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 30 2016
Added on Nov 2 2016
10 comments
717 views