Comma causing a problem while writing CSV

I am trying to write a line into a CSV file which contains a comma. However, the CSV file is considering that ‘,’ to be a delimiter. So, how can we a write a column value which consists of a comma, and we don’t want it to be treated as a delimiter.

Hey @LPLC0059 ,
Enclose that whole sentence under qoutes ,or you can work with pandas.
Working with pandas is more easier.
I hope this helps.
Thank You and Happy Learning :slightly_smiling_face:.

Can you please elaborate a bit on how we can use pandas for this?

Like the same way you are creating a csv file , In pandas what you need to do is .
While scraping the jokes, keep appending them in a array.
Your array should be like :
arr = [ [ Id,joke1 ], [ Id, joke2 ] , ........... ]
( whether your jokes contain , or not , you don’t need to do anything ,just append it.)
and then just do
pd.DataFrame( arr , columns=[ 'ID','jokes' ] ).to_csv("submission.csv",index=False)

It will create your required csv file.

I hope this will help you.
Thank You and Happy Learning :slightly_smiling_face:.

Okay, thank you so much!

No problem :slightly_smiling_face:.
If your doubt is resolved then i would request to kindly mark it as resolved in your course doubt section and also provide your valuable feedback for it too.

Thank You and Happy Learning :slightly_smiling_face:.