Every once in awhile, I’ll have the need to load data from a spreadsheet into a Python program, but one question always comes up: what’s the best w...
For further actions, you may consider blocking this person and/or reporting abuse
One of the main benefits for using the csv library in Python is that it handles edge cases much more gracefully than a custom and naive "split by comma" approach.
A valid csv might look like this:
Here, the split-by-comma approach will actually trip up because it doesn't regard the quoted string as a field.
Good point! I’ll add that note to the first section.
Good article. Another method to be aware of, if you are using the pandas library to process your data further, that library can read a CSV or Excel file into a DataFrame: pandas.pydata.org/pandas-docs/stab...
Probably good to mention in passing that reading/writing XLSX files directly works fine with an add on library