diff --git a/c302/W_SpreadsheetDataReader.py b/c302/W_SpreadsheetDataReader.py index dd01ba8b..a0f9bf56 100644 --- a/c302/W_SpreadsheetDataReader.py +++ b/c302/W_SpreadsheetDataReader.py @@ -6,6 +6,7 @@ spreadsheet_location = os.path.dirname(os.path.abspath(__file__))+"/data/" + from c302 import print_ def read_data(include_nonconnected_cells=False, neuron_connect=False): @@ -14,15 +15,17 @@ def read_data(include_nonconnected_cells=False, neuron_connect=False): conns = [] cells = [] filename = "%switvliet_2020_8_adult.xlsx"%spreadsheet_location - rb = load_workbook(filename) + wb = load_workbook(filename) + sheet = wb.worksheets[0] print_("Opened the Excel file: " + filename) + - for row in range(1,rb.sheet_by_index(0).nrows): - pre = str(rb.sheet_by_index(0).cell(row,0).value) - post = str(rb.sheet_by_index(0).cell(row,1).value) - syntype = rb.sheet_by_index(0).cell(row,2).value - num = int(rb.sheet_by_index(0).cell(row,3).value) - synclass = 'Generic_GJ' if 'EJ' in syntype else 'Chemical_Synapse' + for row in sheet.iter_rows(min_row=2, values_only=True): # Assuming data starts from the second row + pre = str(row[0]) + post = str(row[1]) + syntype = str(row[2]) + num = int(row[3]) + synclass = 'Generic_GJ' if 'electrical' in syntype else 'Chemical_Synapse' conns.append(ConnectionInfo(pre, post, num, syntype, synclass)) if pre not in cells: @@ -36,19 +39,20 @@ def read_data(include_nonconnected_cells=False, neuron_connect=False): conns = [] cells = [] filename = "%switvliet_2020_8_adult.xlsx"%spreadsheet_location - rb = load_workbook(filename) + wb = load_workbook(filename) + sheet = wb.worksheets[0] print_("Opened Excel file..: " + filename) known_nonconnected_cells = ['CANL', 'CANR', 'VC6'] - for row in range(1,rb.sheet_by_index(0).nrows): - pre = str(rb.sheet_by_index(0).cell(row,0).value) - post = str(rb.sheet_by_index(0).cell(row,1).value) - syntype = rb.sheet_by_index(0).cell(row,2).value - num = int(rb.sheet_by_index(0).cell(row,3).value) - synclass = rb.sheet_by_index(0).cell(row,4).value + for row in sheet.iter_rows(min_row=2, values_only=True): + pre = str(row[0]) + post = str(row[1]) + syntype = str(row[2]) + num = int(row[3]) + synclass = 'Generic_GJ' if 'electrical' in syntype else 'Chemical_Synapse' conns.append(ConnectionInfo(pre, post, num, syntype, synclass)) @@ -70,23 +74,22 @@ def read_muscle_data(): muscles = [] filename = "%switvliet_2020_8_adult.xlsx"%spreadsheet_location - rb = load_workbook(filename) + wb = load_workbook(filename) + sheet = wb.worksheets[0] print_("Opened Excel file: "+ filename) - sheet = rb.sheet_by_index(1) - - for row in range(1,sheet.nrows): - pre = str(sheet.cell(row,0).value) - post = str(sheet.cell(row,1).value) - syntype = 'Send' - num = int(sheet.cell(row,2).value) - synclass = sheet.cell(row,3).value.replace(',', 'plus').replace(' ', '_') + for row in sheet.iter_rows(min_row=2, values_only=True): + pre = str(row[0]) + post = str(row[1]) + syntype = str(row[2]) + num = int(row[3]) + synclass = 'Generic_GJ' if 'electrical' in syntype else 'Chemical_Synapse' - conns.append(ConnectionInfo(pre, post, num, syntype, synclass)) - if pre not in neurons: + conns.append(ConnectionInfo(pre, post, num, syntype, synclass)) + if pre not in neurons: neurons.append(pre) - if post not in muscles: + if post not in muscles: muscles.append(post)