Just wondering if there is a way to pass the other arguments than path for the pd.read_csv dynamically ?
filepath='c:\works\abcd.csv'
args = {"delimiter":"|","index_col":"None"}
df=pd.read_csv(filepath,args)
my requirement is to pass multiple parameters like that dynamically.
CodePudding user response:
import pandas as pd
from io import StringIO
filepath="""1|2|3|4
A|B|C|D"""
args = {"delimiter": "|", "index_col": None}
df=pd.read_csv(StringIO(filepath), **args)