0

I want to reference a Questions table/sheet in my database called StudentNames

Where would I implement the reference point so only the Questions sheet is accessed

def QuestionGenerator():
    questionlist_file = open('StudentNames.csv')
    reader=csv.reader(questionlist_file)
    rownum=0
    array2=[]
    for row in reader:
        array2.append(row)
        rownum=rownum+1
    print(array2)
Matt Ellen
  • 11,268
  • 4
  • 68
  • 90
Callum Twig
  • 65
  • 2
  • 9

1 Answers1

0

As noted in the comments, it looks like csv may not be the best format for what you are trying to do. If you already have an excel file with this information, perhaps consider python libraries that have been built for excel, like pandas. The answer to this question references arguments (i.e. sheet_name) that can be passed to the pandas read_excel function to make sure you are only using a specific sheet.

    import pandas as pd
    def QuestionGenerator():
       questionlist_file = pd.ExcelFile('StudentNames.csv')
       sheet_of_interest = pd.read_excel(questionlist_file, 'Questions')
       ...