Outputting HDF5 file using Django framework
NickName:Dex Ask DateTime:2017-04-07T00:52:40

Outputting HDF5 file using Django framework

I'm making a website using the Django framework. I've successfully gotten a web app that takes user data, uses that to make a query, and the outputs a CSV file. However, what I'd really like is to output an HDF5 file. I googled around and there doesn't seem to be any documentation on outputting an HD5F file from a Django web app. I tried adapting the Django example of outputting a PDF (https://docs.djangoproject.com/en/1.10/howto/outputting-pdf/) like this,

response = HttpResponse(content_type='application/hdf5')
response['Content-Disposition'] = 'attachment; filename="test.hdf5"'

h = h5py.File(response)
h.create_dataset('Name', data=test[0].name)

but I get an error,

'HttpResponse' object has no attribute 'encode'

So I guess I'm misunderstanding how to use content_type in Django's HttpResponse. Does anybody have any experience with outputting HDF5 files form a Django web app or could help clarify how I might adapt the HttpResponse to work with HDF5?

Thank you.

Copyright Notice:Content Author:「Dex」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/43261357/outputting-hdf5-file-using-django-framework

More about “Outputting HDF5 file using Django framework” related questions

Outputting HDF5 file using Django framework

I'm making a website using the Django framework. I've successfully gotten a web app that takes user data, uses that to make a query, and the outputs a CSV file. However, what I'd really like is to ...

Show Detail

Reading HDF5 file that was written in java by octave

I'm writing a framework to write HDF5 files that are compatible with Octave. That is, I want that my framework will be able to read HDF5 files that were written by Octave and in a way that Octave w...

Show Detail

Upload File using Django Rest Framework

I am new to django. Can anybody help me... How can I upload a file using the Rest Framework API ? I have tried following this page: http://www.django-rest-framework.org/api-guide/parsers/#

Show Detail

Converting CSV file to HDF5 using pandas

When i use pandas to convert csv files to hdf5 files the resulting file is extremely large. For example a test csv file (23 columns, 1.3 million rows) of 170Mb results in an hdf5 file of 2Gb. Howev...

Show Detail

Obtain the HDF5 file format version of a file

Given a certain HDF5 file (HDF5 format), how can I know the version of the file format that has been used for its creation? Context. It is said in the documentation that when you create/write a fi...

Show Detail

Outputting escaped characters in django templates

I want to use the django templating system to output csv like data which looks like; !connection%block !dosomething !dosomethingelse My,Header,Row,Which,Is,Comma,Seperated All,My,Comma,Seperated,D...

Show Detail

Renaming and removing groups in HDF5 file using HDF5 library

I'm using the HDFview application to modify a HDF5 data file. Basically what I do is check all groups, remove those that match an specific attribute value, rename some groups and adjust attribute v...

Show Detail

Using PyTables to index a 500 GB HDF5 file

I would like to dump a keyed 500GB-800GB table into HDF5, and then then retrieve rows matching specific keys. For an HDF5 file, items like all the data access uses an integer "row" number, so seem...

Show Detail

Django rest framework - File Upload with Ajax , Multipartparser

I'm new bee of django rest framework & django. I can handle some code for CRUD feature using JSON/Ajax in django rest_framework. Now, I want to use feature file uploading especially Image file...

Show Detail

Append hdf5 to another hdf5 file

I have several hdf5 files with the same shape, containing x and y columns. I need to append those, to get one hdf5 file, which contains all the data. My code so far: def append_to_h5(new_file,

Show Detail