Iam Writing a web scraping python program that gets matches details from the web site
like the championship title, teamA title, teamB title, Score, time of the match
When I test the program in the python script it gets me the result as I expected
but when I write it in csv file it gets me horible format for the score like
the actual result of the match is 1-1 and it is written in the csv file like 1-Jan
and 5-0 and written in the csv file May-0
here is the screen of the csv file
CSV file
and here is the screen of the trace of the program
Output of the program
here is the code writing into the csv:
keys = match_details[0].keys()
file_path = 'D:StudyprojectsPython_Projectsweb_scrapingmatches-details.csv'
try:
with open(file_path, 'w', newline='') as output_file:
dict_writer = csv.DictWriter(output_file, fieldnames=keys)
dict_writer.writeheader()
dict_writer.writerows(match_details)
output_file.close()
print("file created")
except PermissionError:
print("Error: The file is open in another program...")
I have tried to solve it but with no progress
Please help!!
Abobaker khaled is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.