Refactoring code
I worked on refactoring my code today. I have been importing several CSV files and decided to generate a function to do the work.
At the beginning of the project, it
was better to import the files individually because each file is different, and
it was better to check the integrity of the file before appending it to the primary
dataset. However, as time passed, the datafiles' layout became more consistent,
and it was better to create a function to do the heavy lifting.
I had problems creating the function,
and this was due to differences in the files and coding errors, but after a few
iterations, it was done.
While the program still takes the
same time to run, the function makes the code cleaner, shorter, and easier to
read.
Overall, today shows the benefits
of working on long projects. These projects tend to grow over time, and it is crucial
to refactor the code periodically, try to automate processes, and use new
techniques.
Here is the code :
Comments
Post a Comment