Image Image Image Image Image Image Image Image Image Image

Oakstree | November 20, 2019

Scroll to top

Top

No Comments

Pandas Replace newlines,tabs,carriage returns in fields

| 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=)

Next Story

This is the most recent story.

Submit a Comment