Creating a zip file in stream without directory structure

I’m working on a Flask app to return a zip file to a user of a directory (a bunch of photos) but I don’t want to include my server directory structure in the returned zip. Currently, I have this : def return_zip(): dir_to_send = ‘/dir/to/the/files’ base_path = pathlib.Path(dir_to_send) data = io.BytesIO() with zipfile.ZipFile(data, mode=’w’) as… Read More Creating a zip file in stream without directory structure

How to check what lineending a StringIO file is using?

I had a method that detects line endings def getLineEnding(filename): ret = "\r\n" with open(filename, ‘r’) as f: f.readline() ret = f.newlines return ret In order to be able to test it without using real files, I changed it to: def getLineEnding(filehandle): filehandle.readline() return filehandle.newlines And this works fine with files. But when I do… Read More How to check what lineending a StringIO file is using?

How to read a csv file with commas in field with pandas python?

Hi I have a csv file with items like this product_id,url 100,https://url/p/Cimory-Yogurt-Squeeze-Original-120-g-745133 "1000,""https://url/p/OREO-Biskuit-Dark-&-White-Chocolate-123,5-g-559227""" 1002,https:/url/p/GARNIER-Micellar-Cleansing-Water-Sensitive-Skin-Pink-125-ml-371378 I tried using import pandas as pd productUrl = pd.read_csv(‘productUrl.csv’,sep=","quotechar=’"’) It returns back as product_id url 100 https://url/p/Cimory-Yogurt-Squeeze-Original-120-g-745133 1000,"https://url/p/OREO-Biskuit-Dark-&-White-Chocolate-123,5-g-559227" 1002 https:/url/p/GARNIER-Micellar-Cleansing-Water-Sensitive-Skin-Pink-125-ml-371378 How do I read the csv? Because the url has commas in there too. >Solution : You do not need… Read More How to read a csv file with commas in field with pandas python?