Skip to content

Commit

Permalink
Merge pull request #5 from ASUS-AICS/fix_special_chars
Browse files Browse the repository at this point in the history
Fix CSV files distortion
  • Loading branch information
whelan9453 authored Dec 24, 2019
2 parents bb1bd8e + 0ebcffc commit 5fab90d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2803,7 +2803,20 @@ def generate():
sleep(0)
s = ''
for item in row:
item = str(item).replace('\n', '')
# Remove extra commas
item = str(item).replace(',', ' ')
# Remove new lines in Windows
if '\r\n' in item:
item = item.replace('\r\n', ' ')
# Remove new lines in Linux and new MacOS
if '\n' in item:
item = item.replace('\n', ' ')
# Remove new lines in old MacOS
if '\r' in item:
item = item.replace('\r', ' ')
# Escape double quotes
if '"' in item:
item = item.replace('"', '""')
s += item + ','
s = s[:-1] + '\n'
yield s
Expand Down

0 comments on commit 5fab90d

Please sign in to comment.