本文整理汇总了Python中Main.getExport方法的典型用法代码示例。如果您正苦于以下问题:Python Main.getExport方法的具体用法?Python Main.getExport怎么用?Python Main.getExport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Main
的用法示例。
在下文中一共展示了Main.getExport方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_trends
# 需要导入模块: import Main [as 别名]
# 或者: from Main import getExport [as 别名]
def find_trends(country_codes,product_codes,is_export):
# Find the Total Product Trends
trends = {}
tag = Main.getExport(is_export)
print ("Getting %s Trends..." % (tag))
for id,country in country_codes.items():
for hs,product in product_codes.items():
five_year_val = Main.getProductCountry(product,country, last_year-5,tag)
first_year_val= Main.getProductCountry(product,country, first_year ,tag)
last_year_val = Main.getProductCountry(product,country, last_year ,tag)
one_year_val = Main.getProductCountry(product,country, last_year-1,tag)
three_year_val= Main.getProductCountry(product,country, last_year-3,tag)
# Attempts to lower the calculation requirements by not calculating for products
# that have no values in the data set given
total = first_year_val + last_year_val + one_year_val + five_year_val + three_year_val
if (total == 0):
continue
if (one_year_val != 0):
one_year_trend = (last_year_val - one_year_val )/ one_year_val
one_year_trend_label = "%s-%s|%s~%s" % (product,"one_year_trend",country,tag)
SQL_Handler.insert("trends",one_year_trend_label,one_year_trend,Main.database)
if (three_year_val != 0):
three_year_trend = ((last_year_val - three_year_val )/ three_year_val)
three_year_trend_label = "%s-%s|%s~%s" % (product,"three_year_trend",country,tag)
SQL_Handler.insert("trends",three_year_trend_label,three_year_trend,Main.database)
if (first_year_val != 0):
long_trend = ((last_year_val - first_year_val )/ first_year_val)
long_trend_label = "%s-%s|%s~%s" % (product,"long_trend",country,tag)
SQL_Handler.insert("trends",long_trend_label,long_trend,Main.database)
if (five_year_val != 0):
five_year_trend = (last_year_val - five_year_val )/ five_year_val
five_year_trend_label = "%s-%s|%s~%s" % (product,"five_year_trend",country,tag)
SQL_Handler.insert("trends",five_year_trend_label,five_year_trend,Main.database)
return trends