I am having problems with modifying a code written by someone else. Basically, trying to get the script to read a list of inputs(gene names) but I'm getting the following error:
NameError: name 'gene_name' is not defined
Below is the code:
import csv
fullout = np.empty((1,3704))
def gene_list(gene_name):
gene_list = open('C:\Users\Work\Desktop\Book1.csv', 'rU'), f
gene_list = []
reader = csv.reader(f)
for row in reader:
gene_name = "row.strip()"
for gene_name in gene_list(gene_name):
if __name__ == '__main__':
with gene_list:
reader = csv.reader(f)
for row in reader:
gene_name = row
probes_dict = get_probes_from_genes(gene_name)
expression_values, well_ids, donor_names = get_expression_values_from_probe_ids_hdf(
probes_dict.keys())
print get_mni_coordinates_from_wells(well_ids)`
gene_name
is defined inside the scope of the function, as remarked by Padraic Cunningham. Once the function is over, you can't use this variable anymore.
I recommend you to read the docs about scopes. Scopes and Namespaces