在将Excel电子表格矩阵转换为python的networkx模块可读的格式时,只需要一点帮助。我曾尝试使用xlrd,但我不知道。请帮助,让我知道是否需要更具体地说明问题。 到目前为止,我使用的代码是:
import xlrd
loc = 'C:\Users\kchen\Desktop\UNSW UNI\Honours\Publishing papers\EVC\Brain matrix\brain 1 matrix.xlsx'
wb = xlrd.open_workbook(loc)
sheet = wb.sheet_by_index(0)
sheet.cell_value(0, 0)
assert isinstance(sheet.nrows, object)
print(sheet.nrows)
loc = 'C:\Users\kchen\Desktop\UNSW UNI\Honours\Publishing papers\EVC\Brain matrix\brain 1 matrix.xlsx'
wb = xlrd.open_workbook(loc)
sheet = wb.sheet_by_index(0)
# For row 0 and column 0
sheet.cell_value(0, 0)
# Extracting number of columns
print(sheet.ncols)