Note that there are some explanatory texts on larger screens.

plurals
  1. POInsert Numpy array into Mysql Database
    primarykey
    data
    text
    <p>Starting with anwser of this: </p> <p><a href="https://stackoverflow.com/questions/6976685/using-numpy-to-create-yahoo-finance-price-table">Using Numpy to create Yahoo finance price table</a></p> <pre><code>import numpy as np import pylab as pl import urllib url = "http://ichart.yahoo.com/table.csv?a=2&amp;c=2011&amp;b=30&amp;e=7&amp;d=7&amp;g=d&amp;f=2011&amp;s=msft&amp;ignore=.csv" f = urllib.urlopen(url) title = f.readline().strip().split(",") data = np.loadtxt(f, dtype=np.float, delimiter=",", converters={0: pl.datestr2num}) </code></pre> <p>I would like to insert return rows into db. data looks like below:</p> <pre><code> [[734233.0 25.98 26.31 25.86 26.15 65581400 25.98] [734232.0 25.82 26.18 25.74 25.78 73694500 25.61] [734231.0 25.45 25.66 25.41 25.55 35433700 25.38] [734228.0 25.53 25.53 25.31 25.48 63114200 25.31] [734227.0 25.60 25.68 25.34 25.39 63233700 25.22] [734226.0 25.60 25.72 25.50 25.61 41999300 25.44]] </code></pre> <p>How would I parse this numpy array to a list or table so I can insert into database. Notice that all row are not separated, but rather one line. The db part works. </p> <p>data.tolist() does not parse single rows</p> <p>looking for output like </p> <pre><code> [[734233.0 ,25.98 ,26.31 ,25.86 ,26.15, 65581400, 25.98] [734232.0, 25.82, 26.18, 25.74, 25.78, 73694500, 25.61] [734231.0, 25.45 ,25.66, 25.41, 25.55, 35433700, 25.38] [734228.0, 25.53, 25.53, 25.31, 25.48, 63114200, 25.31] [734227.0, 25.60 ,25.68, 25.34, 25.39, 63233700, 25.22] [734226.0, 25.60, 25.72, 25.50, 25.61, 41999300, 25.44]] </code></pre> <p>Would replace " " with "," work? </p>
    singulars
    1. This table or related slice is empty.
    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.
 

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