Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

count_spacer.py, syntax issue #3

Open
d3str4d0 opened this issue Oct 30, 2018 · 0 comments
Open

count_spacer.py, syntax issue #3

d3str4d0 opened this issue Oct 30, 2018 · 0 comments

Comments

@d3str4d0
Copy link

d3str4d0 commented Oct 30, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant