-
Notifications
You must be signed in to change notification settings - Fork 77
Closed
Description
HI @joowani, i m in a Mess, i have search around but no answer, i m left with no choice to turn to you.
I m importing List of Google taxonomy product csv files, which have variable headings.
from the code below, the csv file fetch each line, break the lines delimited by '>' then check if fetch an id
from an existing name or create a new name and fetch its id
from the loop below, the code seems not to detect existing name and keep duplicating names. I have tried the normal python code and even with the aql.
can you please give a hint on what i m doing wrong here? what is the correct code?
from arango import ArangoClient
client = ArangoClient(username='mystore', password='chou1979')
import config
app = Flask(__name__)
db = client.db('mystore')
storegraph = db.graph('storegraph')
@manager.command
def fetch_tree():
with open('input.csv') as file:
for row in file.readlines():
items = row.split(' > ')
for item in items:
item = item.rstrip()
item = item.decode('utf-8')
storegraph = db.graph('storegraph')
tax_item = storegraph.vertex_collection('taxonomy')
tax = tax_item.find({'name': item})
tx = db.aql.execute('FOR t IN taxonomy FILTER t.name == @value LIMIT 1 RETURN t', bind_vars={'value': item})
x = [l for l in tx]
if not x:
print item
tax_item.insert({'name': item})
else:
mytax = tax_item.insert({'name':item})
catof = storegraph.edge_collection('catof')
catof.insert({'_from': x[0]['_id'], '_to': mytax['_id']})
Metadata
Metadata
Assignees
Labels
No labels