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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:22:50+00:00 2026-05-23T16:22:50+00:00

I have a database which looks a bit like this: # user1, user2, action,

  • 0

I have a database which looks a bit like this:

# user1, user2, action, days since 01/03/2010, week number, age1, age2, gen1, gen2
['1181206', '3560076', '2', 0, 0, '46', '45', 'M', 'F']
['1291903', '3675534', '2', 0, 0, '32', '30', 'M', 'F']
['3723809', '3686568', '1', 7, 1, '29', '26', 'M', 'F']
['3440145', '3258134', '1', 14, 2, '42', '42', 'M', 'F']
['3720125', '3147358', '1', 15, 2, '50', '51', 'F', 'M']
['2568920', '3753709', '1', 23, 3, '46', '43', 'M', 'F']
['3759313', '3541126', '1', 30, 4, '43', '42', 'M', 'F']
['3372869', '3409372', '1', 37, 5, '44', '45', 'F', 'M']
['2580655', '3816967', '1', 47, 6, '54', '48', 'M', 'F']
['3784183', '1978056', '1', 51, 7, '61', '50', 'M', 'F']
['4462684', '4406304', '1', 59, 8, '52', '51', 'F', 'M']
['3649081', '4524487', '1', 72, 10, '49', '47', 'M', 'F']
['4627173', '4537773', '3', 95, 13, '30', '37', 'F', 'M']
['4697735', '3144685', '1', 106, 15, '28', '29', 'F', 'M']
['3643353', '4740556', '1', 125, 17, '24', '29', 'F', 'M']
...

There are around 5 million rows. Each row represents an activity. user1 does the action on user2.

I need to order it somehow to make it easy to work out the activity for each user,
and in the end what I want to know is:

  • Time in days between a user’s first activity and last activity.
  • Number of users which e.g. have 10-15 days between their first activity and last activity.

I’ve tried sorting it so that each user activity is grouped together but it would take my machine too long! (Around 3 days) Though a quick way of grouping each users activity would be nice.

I’m thinking of setting up a class called Users() which each user is an object in the class with attributes: age , gender and activity.

Then saying:

 for each line in database:
    if user doing the action is an object in the class:
        invoke a method which adds this activity to their activity attribute
    else:
        invoke a method which creates a new user object and add this to their 
activity.

I’m not entirely sure how to do this though, is there a method which can create new objects?

Then somehow looping through all objects in the class working out the number of days between their first and last activity.

I know there are quite a few parts to this so help with any of them is greatly appreciated.

  • 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-23T16:22:51+00:00Added an answer on May 23, 2026 at 4:22 pm

    A rather naïve approach : your ‘Users” structure could be a dictionnary ( http://docs.python.org/tutorial/datastructures.html#dictionaries ) of user activity, where the key could be a username, and the value in the dictionnary would be structure with the oldest and latest activity.

    Then, you browse the list of activities, and each line is either :

    • a new user (you add an object to the dictionnary, and start the oldest and latest activity date with the activity date of the current line).

    • an existing user (you find the activity of this user in the dictionnary, and update the oldest / latest activity dates accordingly)

    In the end you’ll have the activity span of all users.
    Now the database will grow as big as the number of users in your database ; and the processing time will be take a time proportionnal to the amount of rows. This could pose the issues of :

    • reading each line of the database might need some buffering to avoid loading it in memory
    • the dictionnary could be too big to fit in memory if you really have a lot of users

    But both depends on the database and the system you use.

    Hoping this helps.

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

Sidebar

Related Questions

I have a file data.base which looks like: 1234 XXXX 4321 XXXX 9884 ZZZZ
I have a bit of XSLT which is performing some magic on integer database
I have a database which holds the residents of each house in a certain
I have a database which is in Access (you can get it link text
I have a database which I regularly need to import large amounts of data
I have a database which contains picture data stored as a binary blob. The
I have a database which stores (among other things), the following pieces of information:
I have a database which needs to store year ranges (such as lifespan) which
I have a database which users should not be able to alter data in
I have a database which is synchronized against an external web source twice a

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.