I need to create a CSV based on html form input. I have it working, but if someone puts a comma in one of the fields, then there will be an issue. This is very likely to happen due to the expected input. Is there a way to replace commas in the input string before it gets written to the file?
Share
The best way to create CSV files with Python (including automatically dealing with this comma issue) is to use the csv standard library module. You can use this by creating a CSV writer object with
Then you can actually write to the file with
writer.writeroworwriter.writerowsIf you want the columns in your file to be named, you can use a
csv.DictWriter