Pandas Replace newlines,tabs,carriage returns in fields
Aman Khandelwal | On 08, Jul 2019
At times when pandas is converted to csv to bulk upload on database systems like Azure, newlines, tabs and carriage returns make the data break which is why external tables may not function as expected.
The following snippet act an ultimate solutions. It took a while to figure out this.
# got to handle both escaped and literal
df.replace(to_replace=[r"\\t|\\n|\\r", "\t|\n|\r"], value=["",""], regex=True, inplace=