With header information in csv file, city can be grabbed as:
city = row['city']
Now how to assume that csv file does not have headers, there is only 1 column, and column is city.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can still use your line, if you declare the headers yourself, since you know it:
For more information check
csv.DictReaderinfo in the docs.Another option is to just use positional indexing, since you know there’s only one column: