I am working with a file uploaded using Django’s forms.FileField. This returns an object of type InMemoryUploadedFile.
I need to access this file in universal-newline mode. Any ideas on how to do this without saving and then reopening the file?
Thanks
If you are using Python 2.6 or higher, you can use the
io.StringIOclass after having read your file into memory (using the read() method). Example:To actually use this in your django view, you may need to convert the input file data to unicode: