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 6829451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:30:07+00:00 2026-05-26T22:30:07+00:00

I have searched on strings, lists, append etc. but can’t seem to handle this.

  • 0

I have searched on strings, lists, append etc. but can’t seem to handle this.

I have created some files from android based on selections done in an app.
The output looks like this and is in a text file:

House 1,bwfront3,colorfront2,bwtilt3,colortilt3
House 2,bwfront6,colorfront6,bwtilt6,colortilt6
House 3,bwfront5,colorfront5,bwtilt5,colortilt5
House 4,bwfront4,colorfront4,bwtilt4,colortilt4
House 5,bwfront2,colorfront2,bwtilt2,colortilt2

the reason for the naming:

  • I have 5 houses, where the user firstly selects from 9 ‘bwfront..’ pictures. and then between color images and so on.
  • THe exercise is to map different pictures to the ‘house’.

  • I now wish to load the text file(s) and count how many of each of the different ‘bwfront’ have been selected etc. To clarify, the user selects four times per ‘house’.

  • This will continue with all houses + types of pictures,but if any of you can get me started, I should be able to apply the solution to all my 23 files.

Does it make sense?

  • 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-26T22:30:07+00:00Added an answer on May 26, 2026 at 10:30 pm
    # First, create a dictionary for each column, that maps each
    # value (eg colorfront2) to a list of house names.
    results = [{}, {}, {}, {}]
    for filename in os.listdir('/wherever'):
        s = open(os.path.join('/wherever', filename), 'rb').read()
        for line in s.split('\n'):
            if not line.strip(): continue # skip blank lines
            house, values = line.split(',', 1)
            values = values.split(',')
            assert len(values) == len(results) # sanity check
            for value, result in zip(values, results):
                if value not in result:
                    result[value] = []
                result[value].append(house)
    
    
    # Then, do something with it -- e.g., show them in order
    for i, result in enumerate(results):
        print 'COLUMN %d' % i
        def sortkey(pair): return len(pair[1]) # number of houses
        for (val, houses) in sorted(result.items(), key=sortkey, reverse=True):
            print '   %20s occurs for %d houses' % (val, len(houses))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've searched and searched but can't seem to find a way to upload files
I have searched the Web for this, but with no luck. Any idea? Thanks.
Okay I have searched and can't seem to come up with where to find
I have a list of strings. They look like: this.is.the.first.one that.is.the.second thishasnopoint Some of
I have a problem adding strings to a TStringList. I've searched other posts but
I have searched for this, but unfortunately, I don't get the correct answer. class
I have searched the web for a way to do this, but perhaps I'm
I have searched everywhere but can't find a solution that works for me. I
I have searched around, and it seems that this is a limitation in MS
I have searched but apparently my google foo is weak. What I need is

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.