I'm new to python and I would like to extract rows from several csv (better tsv) files in one new excel file with a new column defining the source of the data.
My code for doing it just for one file is:
import pandas as pd
df = pd.read_csv('C:/Users/filename.tsv', names=['c1', 'c2', 'c3', 'c4'], delimiter='\t')
result = df.loc [(df['c2'].isin(['name']))]
result.to_excel(r'C:/Users/filenamenew.xlsx')
But how do I do it for several files? like filename1.tsv; filename2.tsv; filename3.tsv...