I am writing a script in python that will read in data from a text file and perform various operations on the data. It is working perfectly if I specify the extension of my file in this statement with open("file.txt") as f:
. My question is (and I don't even know if this is possible), I have to open a file that someone will provide to me but I let's assume that they will all provide it with different extensions (.txt, .rtf, .odt, .doc). All of the files will have the same layout which is for example:
14 Lucas,13 Markus,7 Peter,4
So essentially:
integer
string,integer
string,integer
string,integer
Is there a way to set the extension in with open("file.txt") as f:
to something like with open("file.*") as f:
that will process all the text files apart from their extension, given they have all the same layout.