Python Error please help!

Status
You're currently viewing only redman06's posts. Click here to go back to viewing the entire thread.
Not open for further replies.

redman06

Smack-Fu Master, in training
75
Hey Guys

New to python wrote this script butr getting error on a mac and im stuck, ant help appreciated!

Code:
UnicodeEncodeError: 'ascii' codec can't encode character '\u2019' in position 370: or

Code:
import csv

supplier = "supplier.csv"
newCSV = "newCSV.csv"
productcodes = "productcodes.txt"
column = 13
skucodes = open(productcodes, "r", encoding='utf8').readlines()
codes = []
for val in skucodes:
    codes.append(val.strip("\n").strip())
supplier = open(supplier, "r", encoding='utf8')
new_csv = open(newCSV, "w", newline = "")
csvwriter = csv.writer(new_csv)
csvreader = csv.reader(supplier)
count = 0
for val in csvreader:
    if(count == 0):
        count += 1
    else:
        if(len(val) > 0):
            if((val[column].strip()) in codes):
                csvwriter.writerow(val)
supplier.close()
new_csv.close()
 
Status
You're currently viewing only redman06's posts. Click here to go back to viewing the entire thread.
Not open for further replies.