I have a problem with my Python script (I'm a beginner), I get an HTML table via a URL and I pass it in a CSV file, so far everything works.
My problem is after, I retrieve the entire table so all the columns but only one interests me, I then retrieve only the column that interests me, but I would like to put the output of this command in a file and I can't.
I try this:
#Get list on site and convert to CSV file
pd.read_html(requests.get('URL').content)[-1].to_csv('output.csv')
#Get only column interest me
col_list = ["Référentiel","Module","Label"]
df= pd.read_csv("output.csv",usecols=col_list)
file_path = 'final.csv'
sys.stdout = open(file_path, "w")
print(df["Module"])
but my result looks like this:
0 test1
1 test1
2 test1
3 test1
4 test1
...
13364 test1
13365 test1
13366 test1
13367 test1
13368 test1
Name: Module, Length: 13369, dtype: object
and I would like the entire CSV with the requested column and not just an overview...