I am very new to Python so bear with me please. I have a folder with csv files where the first row is data I need to work with. So I need to give them column names so I can call them later. Each csv has the same number of columns. For my practice I'm using three columns.
I understand how to add file names to a single file:
my_file = pd.read_csv('path\the_file.csv', names = ['first','second','third'])
But I need to go to my directory and loop through a large number of csv files. I'm honestly not even sure how to do that (sad I know). I've managed to loop through the file names using os.listdir but that isn't much use to me when I need the data in them. I know what to do once I get those column names.
Using pandas whenever possible is highly preferable. I've looked a lot but can't seem to find anything that actually works. I'd really appreciate the help!
edit: This is part of what I'll be doing but need to do for ALL csv files in the folder.
my_file = pd.read_csv('path\the_file.csv', names=['first','second','third'])
first_col = my_file['first']
second_col = my_file['second']
third_col = my_file['third']
key_codes = []
key_codes.append(second.map(str) + third.map(str))
So, if column 2 has, "123" and column 3 has, "4" then I'm making "1234" I'm doing more than that but for now I just need to figure out how to loop through the files and add the same name/header to them all.