title: How do I escape commas while reading CSV files with Python?
body: <p>I have some gzip files that are CSV files. So I'm not using the <code>csv</code> module. </p>
  
  <p>Some character fields are encapsulated within double quotes: <code>"</code>, but not all of them. My goal is to read the lines and basically copy the data to another file. Some of the fields that contain the double quotes have commas in them, and my script isn't properly ignoring commas within the quotes. How do I set it so Python ignores characters within double quotes?</p>
  
  <p>This is part of the code pertaining to the question:</p>
  
  <pre><code>with gzip.open('gzippedfile.csv.gz', 'r') as campaign, open('output%s.csv' % today, 'wb') as output:
          outputwriter = csv.writer(output, delimiter=',')
  
      #Create variable 'count' to hold counter to skip reading the header line in the input file
          count = 0
  
          for line in campaign:
                  line=line.replace('\"','')
                  line=line.replace('\'','')
                  #print line
                  #Increment count by one each loop. This will make the loop skip the header line at the first iteration
                  count = count+1
                  if count == 1:
                          continue    
                  #print today
          #Create strings of the campaignid, whitelist entry, blacklist entry, and zipcode list each row
                  campaignid = line.split(',')[0].lstrip()
                  whitelist = line.split(',')[10].lstrip()
                  blacklist = line.split(',')[11]
                  zipcodes = line.split(',')[12]
  </code></pre>
  
  <p>I've tried removing the <code>replace</code> lines 8 and 9 but that doesn't fix the problem. </p>