Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your data isn't CSV. It's some sort of incomplete Python code. From what you say, the easiest thing would be to add some code at the beginning of your data file, like this:</p> <pre><code># add this from someModule import Item itemList = [] # leave the rest of your data below itemList.append(Item( 'SSCATALOG', 1, "M" ,18 ,2)) itemList.append(Item( 'PTPC36200', 1, "Z" ,19 ,8)) # etc. </code></pre> <p>Here <code>someModule</code> is the Python module where the Item class is defined. If you make these changes, you can then import your data file as a normal Python module and access its <code>itemList</code> variable to get at the data.</p> <p>However, a better long-term solution would be to use a better data format. Don't store the data like this:</p> <pre><code>itemList.append(Item( 'SSCATALOG', 1, "M" ,18 ,2)) </code></pre> <p>store it like this:</p> <pre><code>'SSCATALOG',1,"M" ,18,2 </code></pre> <p>Then it will be a real CSV file. You can import the data with <a href="http://docs.python.org/library/csv.html" rel="nofollow">the <code>csv</code> module</a> and <em>then</em> create your objects then from the data you read in. It's often better not to try to store an object of some user-defined class; instead, store the data you use to create that object, then recreate the object when you read in the data. You could also look at <a href="http://docs.python.org/library/pickle.html" rel="nofollow">the <code>pickle</code> module</a> for reading and writing Python objects to files.</p>
 

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