Remove single and double quotes from a csv file in 3 to 4 column - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Remove single and double quotes from a csv file in 3 to 4 column (/thread-33124.html) |
Remove single and double quotes from a csv file in 3 to 4 column - shantanu97 - Mar-31-2021 If I did not read csv like this then it will give tokenizing error. But when I read like this in some column double quotes are appearing. I need to remove them. Double quotes look this, see attached picture. csv_files=['BK00018384.CSV'] from pathlib import Path import time import pandas as pd import numpy as np import datetime df=pd.DataFrame() for fn in csv_files: all_dfs = pd.read_csv(fn,header=None, sep='\n') all_dfs = all_dfs[0].str.split(',', expand=True) all_dfs[1] = all_dfs[1].apply(lambda x: x.replace('"', "")) all_dfs[2] = all_dfs[1].apply(lambda x: x.replace('"', "")) all_dfs[3] = all_dfs[1].apply(lambda x: x.replace('"', "")) all_dfs[4] = all_dfs[1].apply(lambda x: x.replace('"', "")) all_dfs[4] = all_dfs[1].apply(lambda x: x.replace('-', "")) Want to remove this double quotes. Attach csv file CSV File |