Skip to content

Instantly share code, notes, and snippets.

View Jazzis18's full-sized avatar

Yuri Mashukov Jazzis18

  • Russia, Yekaterinburg
View GitHub Profile
@Jazzis18
Jazzis18 / python django create and download zip.py
Last active June 10, 2024 23:11 — forked from viveksoundrapandi/python django create and download zip
A simple snippet to zip files in a directory and send it the browser in downloadable format in django
from shutil import make_archive
from wsgiref.util import FileWrapper
def download(request, file_name=""):
"""
A django view to zip files in directory and send it as downloadable response to the browser.
Args:
@request: Django request object
@file_name: Name of the directory to be zipped
Returns:
A downloadable Http response
import xlrd
from openpyxl.workbook import Workbook
from openpyxl.reader.excel import load_workbook, InvalidFileException
def open_xls_as_xlsx(filename):
# first open using xlrd
book = xlrd.open_workbook(filename)
index = 0
nrows, ncols = 0, 0
while nrows * ncols == 0: