Closed Shivam7-1 closed 1 year ago
@mlevans can you please review this PR
Hi @Shivam7-1, what is the point of this though?
The original code simply creates a csv file using the pandas to_csv
function and places it in the appropriate location.
Hi @SethiAbhinav as I mentioned above it avoid writing the default row index to the CSV file. And it will be good practice to make code for different parameters also
Right, not writing the index to the csv file is definitely a good step. However, I don't see the point in using the with open(file)...
. I am basically suggesting to change the PR to simply be this change:
df.to_csv('../../data/grievances.csv', index = False)
Hi @SethiAbhinav I have use with statement if in future if code size or CSV file is increased then it will act as exception handling to make the code cleaner and much more readable.
Got it, thanks @Shivam7-1!
In this updated code, the with statement is used to open the file '../../data/grievances.csv' in write mode as the variable 'f'. This ensures that the file is automatically closed when the block is exited, even if an exception is raised. Additionally, the 'index' parameter in the 'to_csv' method is set to 'False' to avoid writing the default row index to the CSV file.