I am trying to take some actions for some csv files in my folder,all those files should have same format,except with different IDs;it looks like: Myfile_100_2018-11-26.csv, all those numbers are different(100 means id,the rest numbers are date time); I have a list object, which contain all ids I want to open, for example my_id=[100,200,300,400]
import pandas as pd
import os
import re
allfiles = os.listdir('.')
game_id=[100,200,300,400]
from id in game_id:
files = [f for f in allfiles if re.search(r'(%s+_\d{4}-\d{2}-\d{2}\.csv$')%game_id, f)]
In my code, I am want to use game_id replace the %s, so that I can loops though all files for ids from 100, 200, 300,400; however I get an error:SyntaxError: invalid syntax for the comma after game_id.
I tried many combination I searched from other questions, but seems didn't work for me, can anyone gives an advice? thanks
)%game_id