r/PythonLearning • • Sep 27 '26

read and write csv file

just learned about functions so tried it out with csv editing

114 Upvotes

6 comments sorted by

•

u/Sea-Ad7805 Sep 27 '26

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

4

u/silvertank00 Sep 27 '26

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 Sep 27 '26

Ok, thank you!

1

u/TreatZealousideal770 Sep 27 '26

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 Sep 27 '26

i imported automation from another py file but thank you

2

u/Ttttereza Sep 28 '26

nice try