I have two separate CSV files. I want to scan through both CSV files and find SKU numbers that match. And if they do match, update the number in sheet 2 from the number in sheet 1 that correlates to its SKU numbers.
import csv
with open("C:\\Users\\Owner\\OneDrive\\Desktop\\Test\\read.csv", 'r') as file:
# Create a CSV reader
reader = csv.reader(file)
rows1 = [row for row in reader]
with open("C:\\Users\\Owner\\OneDrive\\Desktop\\Test\\import.csv", 'r') as file:
reader = csv.reader(file)
rows2 = [row for row in reader]
column1_values = [row[7] for row in rows1]
column2_values = [row[8] for row in rows2]
column3_values = [row[8] for row in rows1]
for row in rows1:
value2 = row[7]
for row in rows2:
value1 = row[8]
if value1 in column1_values and value2 in column2_values:
value3 = column3_values
print(value3)
So far, I have the python code able to read through both files. However I am having trouble with matching the sku numbers and then updating the inventory numbers after.
First File that I want to extract data from:
,,kh10,,,,0
,,kh12,,,,21
,,kh13,,,,1
,,kh11,,,,45
,,kh20,,,,26
Second File that I want to update:
,kh20,,,0
,kh16,,,47
,kh12,,,31
,kh10,,,2
,kh13,,,0
I want to match those KH numbers, and then after from the first file extract the numbers from the last column in the first file and replace the last column in the second file with those numbers.