Loop through multiple CSV files and run a script

后端 未结 4 1306
故里飘歌
故里飘歌 2021-01-28 16:40

I have a script which pulls in data from a csv file, does some manipulations to it and creates an output excel file. But, its a tedious process as I need to do it for multiple f

4条回答
  •  清酒与你
    2021-01-28 17:11

    you can run this scrip inside a for loop:

    for file in os.listdir(INPUT_PATH):
        if file.endswith('.csv') or file.endswith('.CSV'):
            INPUT_FILE = INPUT_PATH + '/' + file
            OUTPUT_FILE = INPUT_PATH  + '/Outputs/' + file.[:-4] + 'xlsx'
    

提交回复
热议问题