I am trying to read a file in Python using the below code:
with open(file) as fp:
data = fp.read()
The above script works well. I however am trying to have the filename included in the output of data
How could I have that included.
Edit:
Adding a sample output with the expected result
Current Output:
col1,col2,col3
1,Prod_A,10
2,Prod_B,5
Expected output:
col1,col2,col3,filename
1,Prod_A,10,sales.csv
2,Prod_B,5,sales.csv