Skip to content

Commit

Permalink
W_SpreadsheetDataReader
Browse files Browse the repository at this point in the history
  • Loading branch information
yasinthanvickneswaran committed Feb 8, 2024
1 parent b5d4416 commit fa254e7
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions c302/W_SpreadsheetDataReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand All @@ -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))
Expand All @@ -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)


Expand Down

0 comments on commit fa254e7

Please sign in to comment.