monum / 311-translation

MIT License
6 stars 13 forks source link

Done important changes while data store in CSV format #11

Closed Shivam7-1 closed 9 months ago

Shivam7-1 commented 1 year ago

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.

Shivam7-1 commented 1 year ago

@mlevans can you please review this PR

SethiAbhinav commented 1 year ago

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.

Shivam7-1 commented 1 year ago

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

SethiAbhinav commented 1 year ago

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)
Shivam7-1 commented 1 year ago

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.

SethiAbhinav commented 1 year ago

Got it, thanks @Shivam7-1!