1

This is not a duplicate question! I got lost when trying to get a list of files but without their extension. I am getting the a list of files in this specific directory using:

files = os.listdir("C:/Users/sp500/")

All files are with ".csv" extension which I would like to remove (I need the list of tickers only).

Using strip as suggested here and using

import os
print(os.path.splitext("path_to_file")[0])

as suggested here, I am getting this error:

TypeError: expected str, bytes or os.PathLike object, not list

doesn't help nor other remove function etc.

I will appreciate your help very much!

Giladbi
  • 1,822
  • 3
  • 19
  • 34

0 Answers0