Skip to content

Instantly share code, notes, and snippets.

View dejmail's full-sized avatar

Liam_Thompson dejmail

  • Gothenburg, Sweden
View GitHub Profile
@dejmail
dejmail / views.py
Created November 4, 2021 12:04 — forked from rg3915/views.py
Read csv InMemoryUploadedFile Django
import csv
import io
def import_csv(request):
if request.method == 'POST' and request.FILES['myfile']:
myfile = request.FILES['myfile']
# Read csv file InMemoryUploadedFile
file = myfile.read().decode('utf-8')
@dejmail
dejmail / pandas_newline_strip.txt
Created April 24, 2019 07:10 — forked from smram/pandas_newline_strip.txt
[pandas] replace newlines,tabs,carriage returns in fields
# got to handle both escaped and literal
df.replace(to_replace=[r"\\t|\\n|\\r", "\t|\n|\r"], value=["",""], regex=True, inplace=<INPLACE>)