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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:33:54+00:00 2026-06-05T15:33:54+00:00

Here is the code for the relevant function: def populateSubscribers(csvfile, db): conn = sqlite3.connect(db)

  • 0

Here is the code for the relevant function:

def populateSubscribers(csvfile, db):
  conn = sqlite3.connect(db)
  conn.text_factory = str  #bugger 8-bit bytestrings
  cur = conn.cursor()

  subscriber_dict = {}

  # read values from tab-delimited csv file
  reader = csv.reader(open(csvfile, "rU"), delimiter = '\t')
  for Number, Name, Message, Datetime, Type in reader:
    if str(Number)[:1] == '1':
      tmpNumber = str(Number)[1:]
      Number = int(tmpNumber)

      # check to ensure name/number not null
      if Number and Name:
        # add unique subscribers to dictionary
        subscriber_dict[Number] = Name
      else:
        print 'Subscriber missing name or number'

  # insert unique subscribers into subscriber table
  for number, name in subscriber_dict.items():
    cur.execute('INSERT OR IGNORE INTO subscriber (name, phone_number) VALUES (?,?)', (name, number))
    conn.commit()

  cur.close()
  conn.close()
  print '...Successfully populated subcriber table.'

It is reading subscriber names and phone numbers from a csv file and then it is supposed to write an entry for each unique subscriber into the database. I wanted the phone number to be the key in key/value pairs since it is unique. But for some reason, it is not reading all of the numbers from the data, it is missing some subscribers. If I make the name the key it misses as would be anticipated (de-duplicates all the Unknowns), but the phone number as key is missing some numbers altogether. Any ideas on how to fix the logic here?

  • 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-06-05T15:33:57+00:00Added an answer on June 5, 2026 at 3:33 pm

    Looks to me like if str(Number)[:1] == '1': is probably filtering out some of your data.

    Add an else to that and print out any it’s rejecting. Those are probably the ones which are going wrong.

    Either way, pare down your input data and find which one’s aren’t being used. Without seeing the data and the alternative you’ve said which does work, it’s hard to pin down the exact cause here.

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

Sidebar

Related Questions

Here's the relevant bit of the source code: class Dice { String name ;
Here's the relevant code snippet. public static Territory[] assignTerri (Territory[] board, String[] colors) {
Here's the relevant code: public static void printBoarders (Territory x) { int t =
I'm having some trouble with the jQuery hover method. Here's the relevant JavaScript code:
Here my code jQuery.fn.dataTableExt.oSort['num-asc'] = function(a,b) { var x = a.replace( /<.*?>/g, ); var
Here's the (relevant) code for my pro::surface class: /** Wraps up SDL_Surface* **/ class
relevant code: function stepNetwork() { for(i = 0; i<maxNeurons; i++) { if(neuronArray[i].charge >= neuronArray[i].threshhold)
I hope I got the relevant code in here. I have some problem when
I've created a function called EnergyPrice with the following code: Here's the pricetable I'm
JSFiddle link: http://jsfiddle.net/dqkZN/32/ Here is the relevant code: <div class=categories> <h3> <img src=http://i.imgur.com/t5UXT.gif />

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.