0

I'm trying to do this with open(fileName,'rb') as csvfile:. It works if I hardcode a name for fileName, but if I use fileName = input("Enter file name: ") I get an error

...
fileName = input("Enter file name: ")
File "<string>", line 1, in <module>
NameError: name 'page1' is not defined

where page1.csv is the intended file and what I enter for when asked for input. How can I fix this?

1 Answer 1

5

You are using Python 2. You need to use raw_input instead of input.

raw_input will give you a string value as you expect. input tries to run it as a Python expression.

Sign up to request clarification or add additional context in comments.

1 Comment

wow thanks for that. I'm not working from my usual computer and totally forgot to check the version. Stupid mistake

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.