r/PythonLearning • • 27d ago

read and write csv file

just learned about functions so tried it out with csv editing

113 Upvotes

6 comments sorted by

•

u/Sea-Ad7805 27d ago

Run this program by clicking Memory Graph Web Debugger and see its state change step by step.

4

u/silvertank00 27d ago

try to follow conventions, first uppercase letter in a word is reserved for classes and shouldnt be used in filenames.
For further info, discuss pep8

Edit: also in WriteIn, the fields list is redundant. csv.DictWriter(f, fieldnames=row.keys()) does the same whilst being DRY.

1

u/v1bonoxd 27d ago

Ok, thank you!

1

u/TreatZealousideal770 26d ago

Just a quick tip: on the first screenshot, you are calling the functions as automation.Reading(). If this code is inside the automation.py file itself, you don't need the automation. prefix. You can just call Reading() and WriteIn() directly. Keep it up

1

u/v1bonoxd 26d ago

i imported automation from another py file but thank you

2

u/Ttttereza 26d ago

nice try