Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The default delimiter in the Python <code>csv</code> module for reading CSV files with <code>csv.reader</code> is comma, so if your CSV file is saved with <code>delimiter=','</code>, it should also be read in properly by default, unless you explicitly specify a wrong delimiter value.</p> <p>CSV file content:</p> <pre><code>foo,bar,baz hello world,again,and again </code></pre> <p>code:</p> <pre><code>&gt;&gt;&gt; list(csv.reader(open('test.csv', 'rb'))) [['foo', 'bar', 'baz'], ['hello world', 'again', 'and again']] </code></pre> <p>as you can see, the spaces in <code>hello world</code> and <code>and again</code> are parsed properly (i.e. ignored).</p> <p>To understand why your code is not working as you want it to work, you'd have to show us more of (the relevant parts of) your code.</p> <p><strong>UPDATE:</strong></p> <p>Based on your edit, it looks like you're using your own code to parse the CSV file—<strong>DON'T DO THAT</strong> (especially if you're just a beginner in programming/Python). Use the built-in <code>csv</code> module.</p> <pre><code>with open('test.csv', 'rb') as f: reader = csv.reader(f, delimiter=',') for row in reader: ... # or just rows = list(reader) </code></pre> <p>Furthermore, your CSV parsing code is extremely inefficient, and probably (or, well, apparently) buggy; but I didn't really go through it to try to find the bug because you can do it yourself (for learning purposes—for real code, use <code>csv.reader</code>).</p> <p>A simple example of a more efficient CSV parsing code would be:</p> <pre><code>with open(filename, 'rb') as f: rows = [line.split(',') for line in f] </code></pre> <p>...but this doesn't take into account quoting; implementing quoting support would not be as trivial and would probably invole using regular expressions or parsing code.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload