<html><head></head><body><div style="color:#000; background-color:#fff; font-family:verdana, helvetica, sans-serif;font-size:16px"><div id="yui_3_16_0_1_1444492481730_3106"><span id="yui_3_16_0_1_1444492481730_3105">What a newbie mistake! Thanks for the help.</span></div><div></div><div id="yui_3_16_0_1_1444492481730_3107"> </div><div class="signature" id="yui_3_16_0_1_1444492481730_3108">Jim
</div><br>  <div style="font-family: verdana, helvetica, sans-serif; font-size: 16px;" id="yui_3_16_0_1_1444492481730_3111"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" id="yui_3_16_0_1_1444492481730_3110"> <div dir="ltr" id="yui_3_16_0_1_1444492481730_3109"> <hr size="1">  <font size="2" face="Arial" id="yui_3_16_0_1_1444492481730_3112"> <b><span style="font-weight:bold;">From:</span></b> Jonathan Chen <tamasiaina@gmail.com><br> <b><span style="font-weight: bold;">To:</span></b> Jim Icenhower <jicenhower@yahoo.com> <br><b><span style="font-weight: bold;">Cc:</span></b> "flask@python.org" <flask@python.org> <br> <b><span style="font-weight: bold;">Sent:</span></b> Saturday, October 10, 2015 10:58 AM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [Flask] Question on iterating over records read using pyexcel<br> </font> </div> <div class="y_msg_container" id="yui_3_16_0_1_1444492481730_3113"><br><div id="yiv1519028757"><div id="yui_3_16_0_1_1444492481730_3115"><div dir="ltr" id="yui_3_16_0_1_1444492481730_3114">Yeah, the issue is that you are not returning anything. If you just do a return record it should not throw an error. </div><div class="yiv1519028757gmail_extra" id="yui_3_16_0_1_1444492481730_3118"><br clear="all"><div id="yui_3_16_0_1_1444492481730_3117"><div class="yiv1519028757gmail_signature" id="yui_3_16_0_1_1444492481730_3116"><br clear="none">~Jonathan C.</div></div>
<br clear="none"><div class="yiv1519028757gmail_quote" id="yui_3_16_0_1_1444492481730_3124">On Sat, Oct 10, 2015 at 8:48 AM, Jim Icenhower via Flask <span dir="ltr"><<a rel="nofollow" shape="rect" ymailto="mailto:flask@python.org" target="_blank" href="mailto:flask@python.org">flask@python.org</a>></span> wrote:<br clear="none"><blockquote class="yiv1519028757gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;" id="yui_3_16_0_1_1444492481730_3123"><div class="qtdSeparateBR"><br><br></div><div class="yiv1519028757yqt6457905149" id="yiv1519028757yqt69948"><div id="yui_3_16_0_1_1444492481730_3122"><div style="color:#000;background-color:#fff;font-family:verdana, helvetica, sans-serif;font-size:16px;" id="yui_3_16_0_1_1444492481730_3121"><div dir="ltr" id="yui_3_16_0_1_1444492481730_3120"><span id="yui_3_16_0_1_1444492481730_3119">I'm getting an error when iterating over the records read from a very simple xlsx file. I've tried reading a csv file and the results are the same. The code below prints the 3 records in the file then it seems like it's attempting to read another record from the records collection. What am I doing wrong?</span></div><div dir="ltr" id="yui_3_16_0_1_1444492481730_3125"><span><br clear="none"></span></div><div dir="ltr" id="yui_3_16_0_1_1444492481730_3127"><span id="yui_3_16_0_1_1444492481730_3126">Thanks!</span></div><div dir="ltr"><span><br clear="none"></span></div><div dir="ltr"><span>Here's the code:</span></div><pre style="font-size:9pt;"><span style="color:#000080;font-weight:bold;"></span></pre><pre style="color:rgb(0,0,0);font-size:9pt;"><span style="color:rgb(0,0,128);">import </span>os<br clear="none"><br clear="none"><span style="color:rgb(0,0,128);">from </span>models <span style="color:rgb(0,0,128);">import </span>Product, ProductType, Event, CarClass, Vehicle, Registrant<br clear="none"><span style="color:rgb(0,0,128);">from </span>flask <span style="color:rgb(0,0,128);">import </span>render_template<br clear="none"><span style="color:rgb(0,0,128);">from </span>flask.ext.appbuilder.views <span style="color:rgb(0,0,128);">import </span>ModelView, BaseView, has_access, expose<br clear="none"><span style="color:rgb(0,0,128);">from </span>flask.ext.appbuilder.charts.views <span style="color:rgb(0,0,128);">import </span>ChartView<br clear="none"><span style="color:rgb(0,0,128);">from </span>flask.ext.appbuilder.models.sqla.interface <span style="color:rgb(0,0,128);">import </span>SQLAInterface<br clear="none"><span style="color:rgb(0,0,128);">from </span>flask.ext.appbuilder.widgets <span style="color:rgb(0,0,128);">import </span>ListBlock, ShowBlockWidget<br clear="none"><span style="color:rgb(0,0,128);">import </span>pyexcel <span style="color:rgb(0,0,128);">as </span>pe<br clear="none"><span style="color:rgb(0,0,128);">from </span>werkzeug <span style="color:rgb(0,0,128);">import </span>secure_filename</pre><pre style="font-size:9pt;"><span style="color:#000080;font-weight:bold;"></span></pre><pre style="color:rgb(0,0,0);font-size:9pt;"><span style="color:rgb(0,0,128);">from </span>app <span style="color:rgb(0,0,128);">import </span>db</pre><pre style="font-size:9pt;"><span style="color:#000080;font-weight:bold;">def </span>doEventsImport():<br clear="none">    <span style="color:#000080;font-weight:bold;">if </span>request.method == <span style="color:#008000;font-weight:bold;">'POST'</span>:<br clear="none">        file = request.files[<span style="color:#008000;font-weight:bold;">'file'</span>]<br clear="none">        <span style="color:#000080;font-weight:bold;">if </span>file <span style="color:#000080;font-weight:bold;">and </span>allowed_file(file.filename):<br clear="none">            filename = secure_filename(file.filename)<br clear="none">            fullName = os.path.join(app.config[<span style="color:#008000;font-weight:bold;">'UPLOAD_FOLDER'</span>], filename)<br clear="none">            file.save(fullName)<br clear="none"><br clear="none">            records = pe.get_records(<span style="color:#660099;">file_name</span>=fullName)<br clear="none">            <span style="color:#000080;font-weight:bold;">for </span>record <span style="color:#000080;font-weight:bold;">in </span>records:<br clear="none">                <span style="color:#000080;font-weight:bold;">print </span>record<br clear="none"></pre><div><span>Console ouput of the 3 records:</span></div><div>{'EventKey': u'TXABCD2014', 'Name': u'Texas All British Car Days 2014-a'}</div><div>{'EventKey': u'TXABCD2015', 'Name': u'Texas All British Car Days 2015'}</div><div>{'EventKey': u'TXABCD2016', 'Name': u'Texas All British Car Days 2016'}</div><div><br clear="none"></div><div>Error stack:</div><div><br clear="none"></div><div>2015-10-10 10:43:31,993:INFO:werkzeug:127.0.0.1 - - [10/Oct/2015 10:43:31] "POST /importEvents HTTP/1.1" 500 -</div><div>Traceback (most recent call last):</div><div>  File "C:\Python27\lib\site-packages\flask\app.py", line 1836, in __call__</div><div>    return self.wsgi_app(environ, start_response)</div><div>  File "C:\Python27\lib\site-packages\flask\app.py", line 1820, in wsgi_app</div><div>    response = self.make_response(self.handle_exception(e))</div><div>  File "C:\Python27\lib\site-packages\flask\app.py", line 1403, in handle_exception</div><div>    reraise(exc_type, exc_value, tb)</div><div>  File "C:\Python27\lib\site-packages\flask\app.py", line 1817, in wsgi_app</div><div>    response = self.full_dispatch_request()</div><div>  File "C:\Python27\lib\site-packages\flask\app.py", line 1478, in full_dispatch_request</div><div>    response = self.make_response(rv)</div><div>  File "C:\Python27\lib\site-packages\flask\app.py", line 1566, in make_response</div><div>    raise ValueError('View function did not return a response')</div><div></div><div dir="ltr">ValueError: View function did not return a response</div><span class="yiv1519028757HOEnZb"><font color="#888888"></font></span><div></div><div> </div><div>Jim
</div></div></div></div><br clear="none">_______________________________________________<br clear="none">
Flask mailing list<br clear="none">
<a rel="nofollow" shape="rect" ymailto="mailto:Flask@python.org" target="_blank" href="mailto:Flask@python.org">Flask@python.org</a><br clear="none">
<a rel="nofollow" shape="rect" target="_blank" href="https://mail.python.org/mailman/listinfo/flask">https://mail.python.org/mailman/listinfo/flask</a><br clear="none">
<br clear="none"></blockquote></div><br clear="none"></div></div></div><br><br></div> </div> </div>  </div></body></html>