Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def load_tsv_to_net(net, file_buffer, filename=None):
lines = file_buffer.getvalue().split('\n')
num_labels = categories.check_categories(lines)
row_arr = list(range(num_labels['row']))
col_arr = list(range(num_labels['col']))
# use header if there are col categories
if len(col_arr) > 1:
df = pd.read_table(file_buffer, index_col=row_arr,
header=col_arr)
else:
df = pd.read_table(file_buffer, index_col=row_arr)
df = proc_df_labels.main(df)
net.df_to_dat(df, True)
net.dat['filename'] = filename
for inst_sig in sigs:
inst_sig_name = inst_sig['col_name']
col_data = inst_sig['data']
for inst_row_data in col_data:
inst_row = inst_row_data['row_name']
inst_value = inst_row_data['val']
row_index = all_rows.index(inst_row)
col_index = all_sigs.index(inst_sig_name)
net.dat['mat'][row_index, col_index] = inst_value
tmp_df = net.dat_to_df()
tmp_df = proc_df_labels.main(tmp_df)
real_net.df_to_dat(tmp_df)