I am having an issue with my program not being able to handle currency objects that I am pulling from excel spreadsheets. The code runs and does what I want other than this error with changing the currencies. Here is the error that shows up when I execute the code. Are there recommendations for this?

FutureWarning: Currency objects will soon be changed so a decimal.Decimal instance is used. (set pythoncom.future_currency to get these objects now.)

Here is the code that I am running:

import sys, os, win32com.client, glob
from win32com.client import constants
xl = Excel_Document()

headerlist = ['STUDYDES','STUDYDES2','EVENTTYPE','AssessmentSOLUTIONTYPE','AssessmenFDNS-TERMINATION','SOLUTIONTYPE','FDNS-TERMINATION','GROUP','SCENARIO','ProviderOASISReservation','CustomerName','RequestedStart_Date']

ListofData = []
Data = []
counter = 1
xlslist = glob.glob('*tblFacilityLog*.xls')



for xls in xlslist:
    headers = {}
    sortedvalues = []
    output = {}
    print 'Opening Workbook: ',xls
    xl.openWorkbook(xls)

    sheetdata = xl.getSheetData('tblAllFacilityLog')
    xl.closeWorkbook()

    for row in sheetdata:
        sortedvalues = []
        for header in headerlist:
            if header in sheetdata[0]:
                output[header] = row[sheetdata[0].index(header)]
            else:
                output[header] = "'None'"

        for header in headerlist:
            sortedvalues.append(output[header])

        Data.append(sortedvalues)

    ListofData.append(Data)

print 'Building Workbook'
print len(Data)
print len(ListofData)

xl.addWorkbook()
xl.addWorksheet("tblFacilityLog9")
xl.selectSheet("tblFacilityLog9")


beginrow = 1
lastrow = beginrow + len(Data)
#xl.pasteData(headerlist, startcol = beginrow, startrow = beginrow, endcol = len(headerlist), endrow = 1)

for Data in ListofData:
    xl.pasteData(Data, startcol = 1, startrow = 1, endcol = len(headerlist), endrow = lastrow)

xl.saveWorkbook("CombinedLog")
xl.closeWorkbook()
xl.closeApp()
有帮助吗?

解决方案

This error means: if it works now ignore the Warning. If it you will not update the pythoncom module then you have no problem. If you want to use a newer version of pythoncom soon then you can try out the new functionality by doing

import pythoncom
pythoncom.__future_currency__ = True # I guess it is True

This is my understanding of the error.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top