How about something like: <dtml-in "PyS_csvimport(fcsv.read())" prefix="pys">
On 14 October 2011 10:29, Jaroslav Lukesh <luk...@seznam.cz> wrote: > Hi all, > > I want upload csv file for direct processing into SQL only, not for save to > ZODB nor LocalFS. Upload for LocalFS already worked for me. > > So I have form: > > <form method="POST" enctype="multipart/form-data"> > <input type="file" name="fcsv" value="" size="50"><br> > <input type="file" name="fcsv2" value="" size="50"><br> > <input type="submit" name="fileupload" value="Upload"> > </form> > > Diagnostic processing: > <dtml-var "fcsv.filename">::<dtml-var "fcsv.headers['Content-Type'] > ">::<dtml-var fcsv> > And what it get: > data_2011.CSV::application/vnd.ms-excel:: > > Su upload worked, but what I can access to data of the uploaded file? > > the dtml-in does not process anything, only displays NO DATA. > > <dtml-in "PyS_csvimport(fcsv)" prefix="pys"> > <dtml-var pys_item><br> > <dtml-else> > NO DATA > </dtml-in> > > PyS_csvimport parse CSV file by line and return array structure like this > [['',''],['','']]. > > If I use TEXTAREA instead of file upload, dtml-in works. > > How to get CSV file content to processing? > > Many thanks, > > Jaroslav Lukesh > > > > PS: HTTP Request loks like that: > > http://myhost/csvimport/ > > POST /csvimport/ HTTP/1.1 > Host: myhost > (......) > Content-Type: multipart/form-data; > boundary=---------------------------30333176734664 > Content-Length: 21822 > -----------------------------30333176734664 > Content-Disposition: form-data; name="fcsv"; filename="data_2011.CSV" > Content-Type: application/vnd.ms-excel > > (....bulk od CSV data.....) > -----------------------------30333176734664 > Content-Disposition: form-data; name="fcsv2"; filename="data_2011_kd.CSV" > Content-Type: application/vnd.ms-excel > > (....bulk od CSV data.....) > -----------------------------30333176734664 > Content-Disposition: form-data; name="fileupload" > > Upload > -----------------------------30333176734664-- > > HTTP/1.1 200 OK > Server: Zope/(Zope 2.10.13-final, python 2.4.6, linux2) ZServer/1.1 > Date: Fri, 14 Oct 2011 09:21:48 GMT > Content-Length: 2389 > Content-Type: text/html; charset=cp1250 > > _______________________________________________ > Zope maillist - Zope@zope.org > https://mail.zope.org/mailman/listinfo/zope > ** No cross posts or HTML encoding! ** > (Related lists - > https://mail.zope.org/mailman/listinfo/zope-announce > https://mail.zope.org/mailman/listinfo/zope-dev ) > -- Peter Bengtsson, home www.peterbe.com fun kwissle.com work www.mozilla.com _______________________________________________ Zope maillist - Zope@zope.org https://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope-dev )