I'm new to Python and trying to analyse some data. So I've imported and concatenated all the csv files in a folder into a single dataframe. I'm trying to extract part of the file name to use as a header and after searching, I find that you'd normally use regex.
The filenames are like this: 'Varying Concentration2_20190712-145158_Base Media.csv', 'Varying Concentration2_20190712-145158_250 g per l.csv', etc
So the part I'm trying to extract is after the _ and before the .csv.
I've tried:
for fname in all_data:
res = re.findall("(?<=_)(\w+).csv$", fname)
if not res: continue
print (res)
and also "(?<=[0-9]+_)(\w+)"
but it does not seem to work.
The desired output would be a list containing 'Base Media', '150g per l' and so on.