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

  • Home
  • SEARCH
  • 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 255871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:58:00+00:00 2026-05-11T21:58:00+00:00

I’ve got a data source that provides a list of objects and their properties

  • 0

I’ve got a data source that provides a list of objects and their properties (a CSV file, but that doesn’t matter). Each time my program runs, it needs to pull a new copy of the list of objects, compare it to the list of objects (and their properties) stored in the database, and update the database as needed.

Dealing with new objects is easy – the data source gives each object a sequential ID number, check the top ID number in the new information against the database, and you’re done. I’m looking for suggestions for the other cases – when some of an object’s properties have changed, or when an object has been deleted.

A naive solution would be to pull all the objects from the database and get the complement of the intersection of the two sets (old and new) and then examine those results, but that seems like it wouldn’t be very efficient if the sets get large. Any ideas?

  • 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-11T21:58:00+00:00Added an answer on May 11, 2026 at 9:58 pm

    The standard approach for huge piles of data amounts to this.

    We’ll assume that list_1 is the “master” (without duplicates) and list_2 is the “updates” which may have duplicates.

    iter_1 = iter( sorted(list_1) ) # Essentially SELECT...ORDER BY
    iter_2 = iter( sorted(list_2) )
    eof_1 = False
    eof_2 = False
    try:
        item_1 = iter_1.next()
    except StopIteration:
        eof_1= True
    try:
        item_2 = iter_2.next()
    except StopIteration:
        eof_2= True
    while not eof_1 and not eof_2:
        if item_1 == item_2:
            # do your update to create the new master list.
            try:
                item_2 = iter_2.next()
            except StopIteration:
                eof_2= True
        elif item_1 < item_2:
            try:
                item_1 = iter_1.next()
            except StopIteration:
                eof_1= True
        elif item_2 < item_1:
            # Do your insert to create the new master list.
            try:
                item_2 = iter_2.next()
            except StopIteration:
                eof_2= True
    assert eof_1 or eof_2
    if eof_1:
        # item_2 and the rest of list_2 are inserts.
    elif eof_2:
        pass
    else:
        raise Error("What!?!?") 
    

    Yes, it involves a potential sort. If list_1 is kept in sorted order when you write it back to the file system, that saves considerable time. If list_2 can be accumulated in a structure that keeps it sorted, then that saves considerable time.

    Sorry about the wordiness, but you need to know which iterator raised the StopIteration, so you can’t (trivially) wrap the whole while loop in a big-old-try block.

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

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I have a JSP page retrieving data and when single or double quotes are
I want to count how many characters a certain string has in PHP, but
i got an object with contents of html markup in it, for example: string
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.