Pandas reading csv files with partial wildcard

后端 未结 4 1743
天涯浪人
天涯浪人 2021-01-05 13:45

I\'m trying to write a script that imports a file, then does something with the file and outputs the result into another file.

df = pd.read_csv(\'somefile2018.

4条回答
  •  梦毁少年i
    2021-01-05 14:40

    glob returns a list, not a string. The read_csv function takes a string as the input to find the file. Try this:

    for f in glob('somefile*.csv'):
        df = pd.read_csv(f)
        ...
        # the rest of your script
    

提交回复
热议问题