I have multiple .txt files and I want to convert them to .csv files with the same name. The filename for these .txt files is something like this:
01-09-2022-something.txt
02-09-2022-something.txt
03-09-2022-something.txt
04-09-2022-something.txt
.
.
.
.
31-09-2022-something.txt
I need to convert files like these to .csv but with the same name. Can anyone help me with this ?
Currently, I wrote this code to convert but for this, I have to know the file name and in my case filename is not static it is dynamic.
import pandas as pd
file_path = "/var/opt/something.txt"
dataframe1 = pd.read_csv(file_path, delim_whitespace=True)
dataframe1.to_csv('something.csv', index = None)