Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6965493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:04:07+00:00 2026-05-27T16:04:07+00:00

I have a py file using Qt Designer,i have a combobox and i read

  • 0

I have a py file using Qt Designer,i have a combobox and i read from a csv file.If the combobox choice is in the file,it prints something.

At the top of the script it says that: # -*- coding: utf-8 -*-

So, the error i get is this:

PyQt4.QtCore.QString(u'choice') is not in list

The ‘choice’ is of course in list.I believe its an encoding problem,but that’s all i got.

u’choice’ is a string and the list contains strings.

This is how i add items to the list:

import csv
list1=csv.reader(open('file.csv', "rb"))
list2=[]
for i in list1:
   list2.append(i)

Any ideas?Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:04:07+00:00Added an answer on May 27, 2026 at 4:04 pm

    This has got nothing to do with encodings.

    The error occurs simply because there are no strings in the list read from the csv file:

    >>> import csv
    >>> with open('tmp.csv', 'wb') as stream:
    ...     csv.writer(stream).writerow(['choice'])
    ... 
    >>> lst = []
    >>> with open('tmp.csv', 'rb') as stream:
    ...     for row in csv.reader(stream):
    ...         lst.append(row)
    ... 
    >>> from PyQt4.QtCore import QString
    >>> s = QString(u'choice')
    >>> lst.index(s)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ValueError: PyQt4.QtCore.QString(u'choice') is not in list
    >>> lst
    [['choice']]
    >>> lst[0].index(s)
    0
    

    The csv reader returns a list of strings for each row in the file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file that I want to read in using the File::Slurp module
I have .zip file which contain csv data. I am reading .zip file using
I have a Java process that opens a file using a FileReader. How can
I have to write an XML file using java.The contents should be written from
I have found that creating a zip file using the Zip task provided by
I have a Java program that opens a file using the RandomAccessFile class. I'd
I have an edmx file that I generated using edmgen2, I am using the
I am using Qt Designer to create a QWizardPage. I have imported the file
I am using Visual Studio 2010, and I have a LINQ-to-SQL DBML file that
I have class A derived from a Windows.Form class, using the VS2008 designer. When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.