'Using Python/Pandas to loop over several csv files in a folder and make changes to each csv file

I currently have several csv files in a folder. I am wanting to use Python to loop over the files in the folder and make small changes to each csv file. Please see my code below which is not currently working:

import os
import pandas as pd

folder_to_view = "C:/path"

for file in os.listdir(folder_to_view):

    df = pd.read_csv(file)

    df.columns = ['Location','Subscriber','Speed','IP','Start','End','Bytes','Test Status','Comment']

    df.to_csv(file, index=False)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source