You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently wanted to use your count_spacer.py script but ran into and issue:
File "count_spacers.py", line 36
dictionary = {rows[0]:0 for rows in reader}
^
SyntaxError: invalid syntax
The way I get it, the purpose if this piece of code is to read the input csv file containing the spacer sequences (single column .csv file w/o column name?) and then to initiate a dictionary by pasting the spacer sequences into 'dictionary'
when I run the following in the interpreter:
with open(input_file, mode='rU') as infile: #rU mode is necessary for excel!
reader = csv.reader(infile)
for rows in reader:
print(rows[0])
I can see that it picks up the spacer sequences as intended. By..
dictionary = {rows[0]:0 for rows in reader}
you pair every key entry from rows[0] with a value '0' , which in turn should be overwritten later on?
While the syntax looks valid to me, I possess only basic knowledge of python.
I use Python3.6. I wonder if I am missing anything here?
best,
EDIT:
a simple rewrite solves the issue.
for rows in reader:
dictionary={rows[0]:0}
I still don't get why your style did not work, suspect a Python version-specific issue, which has nothing to do with the script itself.
The text was updated successfully, but these errors were encountered:
Hi,
I recently wanted to use your count_spacer.py script but ran into and issue:
File "count_spacers.py", line 36
dictionary = {rows[0]:0 for rows in reader}
^
SyntaxError: invalid syntax
The way I get it, the purpose if this piece of code is to read the input csv file containing the spacer sequences (single column .csv file w/o column name?) and then to initiate a dictionary by pasting the spacer sequences into 'dictionary'
when I run the following in the interpreter:
with open(input_file, mode='rU') as infile: #rU mode is necessary for excel!
reader = csv.reader(infile)
for rows in reader:
print(rows[0])
I can see that it picks up the spacer sequences as intended. By..
dictionary = {rows[0]:0 for rows in reader}
you pair every key entry from rows[0] with a value '0' , which in turn should be overwritten later on?
While the syntax looks valid to me, I possess only basic knowledge of python.
I use Python3.6. I wonder if I am missing anything here?
best,
EDIT:
a simple rewrite solves the issue.
for rows in reader:
dictionary={rows[0]:0}
I still don't get why your style did not work, suspect a Python version-specific issue, which has nothing to do with the script itself.
The text was updated successfully, but these errors were encountered: