Python Forum
Help|CSV Writing on List with Inner Commas
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help|CSV Writing on List with Inner Commas
#1
Let's say I have:
l = ['Washington, 98373, USA', 'Arlington, WA, 98223, USA', 'Soap Lake, Washington, 98851, USA']
What I'm doing is just typical writing
with open('results.csv', 'w', newline='') as f:
    f.write(str(l))
NOTE: I probably cannot write with a list, giving me error(s):
TypeError: write() argument must be str, not list
So my csv would like like:
[Image: 1scoYhF.png]

What I want to write is:
[Image: 2B4JODZ.png]

Hope you can help me out guys and Thanks in advance for your suggestions!

NOTE: It seems the
Reply


Messages In This Thread
Help|CSV Writing on List with Inner Commas - by soothsayerpg - Jul-20-2019, 02:18 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Commas issue in variable ddahlman 6 541 Apr-05-2024, 03:45 PM
Last Post: deanhystad
  help with commas in print functions kronhamilton 11 3,595 Feb-10-2022, 02:02 PM
Last Post: mishraakash
  Writing list as a file, then reading that file as a list Zoastria_Balnala 3 2,660 Oct-17-2019, 07:54 PM
Last Post: Zoastria_Balnala
  [split] Automate the boring stuff, inserting commas in list srikanth 1 2,150 Jul-02-2019, 02:29 PM
Last Post: metulburr
  Automate the boring stuff, inserting commas in list DJ_Qu 3 4,785 Apr-21-2019, 03:52 PM
Last Post: perfringo
  accessing array without commas rjnabil1994 1 2,550 Feb-10-2019, 06:29 PM
Last Post: Larz60+
  Help writing code to create a ranked list swilson421 2 2,498 Jul-16-2018, 04:51 PM
Last Post: swilson421
  Printing array without commas pawlaczkaj 1 9,522 Apr-08-2018, 07:05 PM
Last Post: Larz60+
  How to change from printFacts ( ) to return a list & Loop over list when writing CSV Ivan1 14 8,440 Aug-30-2017, 12:14 PM
Last Post: metulburr
  Writing List to CSV tkj80 6 5,804 Apr-11-2017, 11:14 AM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020