0

I am trying to automate (selenium) the process of writing the contents of my transcript to a csv file with python. So far I have automated the clicks to reach the page with the table. Currently I am only able to display the first row of the table, but the full content of that row appears in one cell.

This is currently the code I have pertinent to writing the contents of my transcript.

id = 1 enter image description here

This is how the HTML table code looks like:

enter image description here

For every table row, the id number increases by 1. For example, VAR_STC_COURSE_NAME_1, VAR_STC_COURSE_NAME_2, etc. The number of rows changes as well depending on the number of courses taken.

I expect a csv file with rows and separate columns for every field. Currently I get the contents of one row in one cell.

1
  • Please do not post snapshot.Post your code in text format so that OP can provide you solution. Commented Nov 6, 2019 at 15:17

1 Answer 1

1

Import csv first and then use csv.writer and writerow([]).

It will write data for each row.The code covers for csv part only.

import csv

with open('testfile.csv','w', newline='') as d:
  for row in main_table:
       csv.writer(d).writerow([course_name.text,grade.text,course_credits.txt,ceus.text,repeat_list.txt,term_list.txt])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.