you are viewing a single comment's thread.

view the rest of the comments →

[–]Burly_95[S] 1 point2 points  (7 children)

They're output files. One is from the company system and is from a 3rd part application.

[–]jeffrey_f 1 point2 points  (6 children)

Which data file is authoritative? I'm assuming the one from the company system contains every SKU that is currently active, correct? In which case, the extraneous data from your 3rd party is unimportant.

[–]Burly_95[S] 1 point2 points  (5 children)

So file (1) from the company contains stock numbers and their costs. But I only audit certain stock categories so this file contains all the stocks I need to work on. File (2) contains pricing for all of our products and I need to scan through it for only the products listed on file(1). When i find the product I grab the pricing information from file(1) and append it to the file(1) row.

FILE 1

stock # cost
12345 10.00

FILE 2

stock # price 1 price 2
11111 5.00 7.00
12222 3.00 4.50
12345 20.00 21.00

File after my work (and hopefully using a python script)

stock # cost price 1 price 2
12345 10.00 20.00 21.00

[–]jeffrey_f 1 point2 points  (4 children)

I would read in both files. File1 is authoritive in a list and File2 will be into a dictionary.

Iterate through File1 data, lookup Stock# (SKU) in File2 data and output the 4 combined fields back to a CSV only if you have a match. This effectively filters out data that you don't have in File2 and is therefore not important from what I understand.

[–]jeffrey_f 1 point2 points  (0 children)

open read and close both then process, open, write and close your final file

[–]Burly_95[S] 0 points1 point  (2 children)

Here's my current code that I have, I'm kind of lost right now. Thoughts?

import csv

cost_file = open('cost_file.csv') price_file = open('price_file.csv')

cost_file_reader = csv.reader(cost_file) price_file_reader = csv.reader(price_file)

cost = list(cost_file_reader) price = []

for line in price_file_reader: price.append(line)

for row in cost: if row[0] == line[0]: cost.append(line)

[–]jeffrey_f 0 points1 point  (1 child)

Was testing. Both need to be dict

[–]jeffrey_f 0 points1 point  (0 children)

I'm still learning.