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
list Sent: Sat, Jan 15, 2022 3:56 pm Subject: Writing a string with comma in one column of CSV file 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) + &

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

Writing a string with comma in one column of CSV file

2022-01-15 Thread Mahmood Naderan via Python-list
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 key is a string which may contain ',' and this causes the final CSV file to have