python csv manipulation

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

Chipko

Ars Scholae Palatinae
975
Subscriptor
What is the error you're getting? it's really hard to help without the .csv files. can you post an example of what they look like?

Add a print statement after the madison.close() line to have a look at what you've actually saved in your price dictionary.

it's also good practice to open file using the with statement:

Code:
>>> with open('workfile', 'r') as f:
...     read_data = f.read()

This ensure that the file is closed if an error occurs when the file is open.

Please also be aware that that opening a file in write mode in
Code:
products_file = open("products.csv","w",newline='',encoding='utf8')
will erase all data in products.csv. maybe this is what you want but i'd recommend to use different file name for the output, atleast during development.
 
Status
You're currently viewing only Chipko's posts. Click here to go back to viewing the entire thread.
Not open for further replies.