remove BOM in columns (pandas, python)
import pandas as pd
import re
table = pd.read_csv('some_file_with_BOM.csv', sep=',', encoding='utf-16-le')
regex = '([a-zA-Z0-9_-])' # You can add any other character you wish to keep
table = table.rename(columns=dict((col, ''.join(re.findall(regex, col))) for col in table.columns))
Written by Paulo Rosário
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#