Re: Writing a string with comma in one column of CSV file

2022-01-16 Thread Greg Ewing
On 17/01/22 4:18 am, Mats Wichmann wrote: the convention for Excel, which is usually the reason people are using csv, is you can enclose the entire comma-containing field in "quote marks" (afaik it must be double-quote). And to include a double quote in a field, quote the field and double the d

Re: Writing a string with comma in one column of CSV file

2022-01-16 Thread Mats Wichmann
On 1/15/22 13:56, Mahmood Naderan via Python-list wrote: > Hi, > I use the following line to write some information to a CSV file which is > comma delimited. > > f = open(output_file, 'w', newline='') > wr = csv.writer(f) > ... > f.write(str(n) + "," + str(key) + "\n" ) > > > Problem is that ke

Re: Writing a string with comma in one column of CSV file

2022-01-15 Thread Avi Gross via Python-list
Mahmood, Ask yourself WHY you want to do what you are doing. Are you using the power and features of the language or trying to do it step by step in the way that earlier languages often made you do it? Yes, there are ways to include commas in fields of a CSV file and they can lead to complicatio

Re: Writing a string with comma in one column of CSV file

2022-01-15 Thread Mahmood Naderan via Python-list
Right. I was also able to put all columns in a string and then use writerow(). Thanks. Regards, Mahmood On Saturday, January 15, 2022, 10:33:08 PM GMT+1, alister via Python-list wrote: On Sat, 15 Jan 2022 20:56:22 + (UTC), Mahmood Naderan wrote: > Hi, > I use the following lin

Re: Writing a string with comma in one column of CSV file

2022-01-15 Thread alister via Python-list
On Sat, 15 Jan 2022 20:56:22 + (UTC), Mahmood Naderan wrote: > Hi, > I use the following line to write some information to a CSV file which > is comma delimited. > > f = open(output_file, 'w', newline='') > wr = csv.writer(f) > ... > f.write(str(n) + "," + str(key) + "\n" ) > > > Problem is

Re: Writing a string with comma in one column of CSV file

2022-01-15 Thread dn via Python-list
On 16/01/2022 09.56, Mahmood Naderan via Python-list wrote: > Hi, > I use the following line to write some information to a CSV file which is > comma delimited. > > f = open(output_file, 'w', newline='') > wr = csv.writer(f) > ... > f.write(str(n) + "," + str(key) + "\n" ) > > > Problem is that