// lets try to figure out if its a csv
try:
data.seek(0)
full = len(data.read())
data.seek(0)
bytes_to_read = int(full*0.3)
dialect = csv.Sniffer().sniff(data.read(bytes_to_read))
After Change
// lets try to figure out if its a csv
try:
data.seek(0)
first_few_lines = []
i = 0
for line in data:
i += 1
first_few_lines.append(line)