擅长:python、mysql、java
<p>这听起来像是我在关系型(即SQL)数据库中做的事情,那里有很多工具来验证数据并确保数据保持一致</p>
<p>如果要在Python中执行此操作,可以执行以下操作:</p>
<pre><code># put your "lists of prices" into a dictionary, keyed by the reference number
# assuming the prices is in the form [(ref1, price1), (ref2, price2)]
ref_prices = {}
for ref, price in PRICE_list:
ref_prices[ref] = price
# do the same for each additional list:
# shorter syntax than the above
ref_quantity = {ref: qty for ref, qty in QTY_list}
# combine all of the above and write into a file
with open(filename, 'w') as fd:
out = csv.writer(fd, delimiter=';')
for id, ref in ID_list:
out.writerow((id, ref, ref_prices[ref], ref_quantity[ref]))
</code></pre>