Reading and uploaded csv file

View: New views
1 Messages — Rating Filter:   Alert me  

Reading and uploaded csv file

by Alex-118 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi all.

I'm working on a small webapp with cherrypy that read an uploaded CSV
file and transform it in XML.
Now my problem is that when I try to read the content of the uploaded
file with csv.reader the file seams to be empty, but when I look at
the content with myFile.file.read() I can see the expected content.
So how can I use the csv module to read and uploaded file?

Thanks in advance.

Here is the relevant part of the code (mostly taken from the
tutorial).

class FileDemo(object):

    def index(self):
        return """
        <html><body>
            <form action="upload" method="post" enctype="multipart/
form-data">
            filename: <input type="file" name="myFile" /><br />
            <input type="submit" />
            </form>
        </body></html>
        """
    index.exposed = True

    def upload(self, myFile):
        out = """<html>
        <body>
                %s
        </body>
        </html>"""

       csvfile = csv.reader(myFile.file) # when I look in th csvfile
it seams there are no rows
      content = myFile.file.read()        # here I can see the
expected content

....

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users@...
To unsubscribe from this group, send email to cherrypy-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---