Skip to content

Instantly share code, notes, and snippets.

@bmaingret
Created March 20, 2021 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmaingret/8943d4eca52f37ab557580303017e8e5 to your computer and use it in GitHub Desktop.
Save bmaingret/8943d4eca52f37ab557580303017e8e5 to your computer and use it in GitHub Desktop.
Convert XLSX to CSV supporting multi-line cells
import pandas as pd
infile = pd.read_excel(r'myfile.xlsx')
infile = infile.replace(to_replace=[r"\\t|\\n|\\r", "\t|\n|\r"], value=["",""], regex=True)
infile.to_csv(r'myfile.csv', index=False, header=True, quoting=csv.QUOTE_ALL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment