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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:40:00+00:00 2026-05-26T16:40:00+00:00

I have two columns in a text file. I read them into Python into

  • 0

I have two columns in a text file. I read them into Python into two separate lists. What I want to do is count the occurences of each pair and build association rules based on it.

Example:

colA = [a,b,c,d,...]

colB = [c,y,d,e,...]

I came only so far to read the data into the two lists but what is the best way to count the occurences and build the rules?

Code:

pred = []
succ = []
for line in open('arsample.txt'):
    lst = line.split('\t')
    pred.append(int(lst[0]))
    succ.append(int(lst[1]))

Rules would look like this and are sorted descending:

P   S   Probability
---------------------
a > c   count(a>c)/n
...     ...
  • 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-26T16:40:01+00:00Added an answer on May 26, 2026 at 4:40 pm

    Have a look on sets :

     http://docs.python.org/library/sets.html
    

    They allow this :

    >>> a = [1,2,2,5,4,5,4,2,1,3]
    >>> set(a)
    set([1, 2, 3, 4, 5])
    >>>
    

    So you will have to build the pairs in a list of strings, I guess…

    Hope it can help.

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

Sidebar

Related Questions

I want to read a long text file in two-column format on my terminal.
I'm using NHibernate 2.1.2 and Spring 1.3 I have two Text columns (blobs) in
I have NSTableView with two columns, and i wanna fill them entries from SQLite
i have two text files file 1 number,name,account id,vv,sfee,dac acc,TDID 7000,john,2,0,0,1,6 7001,elen,2,0,0,1,7 7002,sami,2,0,0,1,6 7003,mike,1,0,0,2,1
I have a form with two text boxes, in one I want to show
Given a tabbed delimited text file with two columns name and date: Sam 20100101
What I have: two columns of text data, that are given to contain only
Let's say I have a tab-delimited text file that contains data arranged in columns
I have two arrays built while parsing a text file. The first contains the
I have a file with two columns, one has the content type of HTTP

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.