Home > Enterprise >  Python pd.read_csv() pass arguments dynamically
Python pd.read_csv() pass arguments dynamically

Time:10-23

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:

What does ** mean in pyhton

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)
  • Related