Skip to content

Commit

Permalink
The average column was removed from EDCD/FDevIDs/commodity.csv
Browse files Browse the repository at this point in the history
  • Loading branch information
bgol committed Sep 19, 2017
1 parent eec383f commit c8df3a7
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions plugins/edcd_plug.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,24 @@ def check_edcd_local(self):
insColumns = [
"name",
"category_id",
"avg_price",
"fdev_id"
]
insValues = [
itemEDCD.dbname,
catEDCD.dbname,
itemEDCD.avgPrice,
itemEDCD.fdevID
]
if itemEDCD.avgPrice:
insColumns.append('avg_price')
insValues.append(itemEDCD.avgPrice)
sqlStmt = (
"INSERT INTO Item({}) VALUES(?,"
"(SELECT category_id "
"FROM Category WHERE name = ?),?,?)"
.format(",".join(insColumns))
"FROM Category WHERE name = ?),?{})"
.format(
",".join(insColumns),
",?" if itemEDCD.avgPrice else ""
)
)
tdenv.DEBUG0("SQL-Statement: {}", sqlStmt)
tdenv.DEBUG0("SQL-Values: {}", insValues)
Expand Down Expand Up @@ -218,10 +222,11 @@ def process_fdevids_items(self, localPath, tableName):
tdenv.DEBUG0("idxMap: {}", idxMap)

notGood = False
for checkMe in ('id', 'category' , 'name' , 'average'):
for checkMe in ('id', 'category', 'name'):
if checkMe not in idxMap:
tdenv.WARN("'{}' column not in {}.", checkMe, localPath)
notGood = True
hasAverage = True if 'average' in idxMap else False

def castToInteger(val):
try:
Expand All @@ -243,7 +248,10 @@ def castToInteger(val):
edcdId = lineIn[idxMap['id']].strip()
edcdCategory = lineIn[idxMap['category']].strip()
edcdName = lineIn[idxMap['name']].strip()
edcdAverage = lineIn[idxMap['average']].strip()
if hasAverage:
edcdAverage = lineIn[idxMap['average']].strip()
else:
edcdAverage = None

if edcdCategory.lower() == "nonmarketable":
# we are, after all, a trading tool
Expand Down

0 comments on commit c8df3a7

Please sign in to comment.