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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:44:34+00:00 2026-05-20T19:44:34+00:00

I am working in Python, but this is a general design question so general

  • 0

I am working in Python, but this is a general design question so general answers are welcome. I will explain the context not as part of the question, but to serve as an example:

I have a script which receives a CSV file, it uses the fields in this file to make automated phone calls. The fields represent names to be spoken, dates to be spoken, and the phone numbers to call. For example, input like “555-555-4321,Bob,Jill,3/30/2011” a phone call might be placed to 555-555-4321 and a robotic message delivered saying “Bob, don’t forget Jills birthday is next Wednesday, one week from now.”

My question is what design patterns would be useful for making this system configurable? More specifically, I’d like to specify what the format the input lines take, and some behaviors for generating the voice message. Some fields, like “Bob,” can be as simple as “speak the field.” Other fields, like the date, require some transformation in order to be spoken (ie, how does “3/30/2011” become “next Wednesday”). I’d also like to have various line formats, for example, input such as “555-555-4321,Bob,6:00” might call Bob every day at 6:00 and say “wake up!”

My goal is to have a web interface which allows defining and configuring these types of things. I know how to solve these problems by hacking my source code, but hacking the source code is a long ways from a simple and user friendly front-end.

  • 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-20T19:44:34+00:00Added an answer on May 20, 2026 at 7:44 pm

    I’m solving a related but not identical problem currently.

    My solution is to create a control list of the same length as the target csv lines, where each element in the control list is the name of a useMethod. In my case the useMethod is an editor widget; in your case, it would be a function that defines how the field is interpreted by your text-to-speech engine. For each line, you can then iterate over the fields, calling the appropriate processing widget.

    So for your example of “555-555-4321,Bob,Jill,3/30/2011”,

    import csv
    def phoneNumber(number):
        ...
    def userName(name):
        ...
    def targetDate(datestring):
        ...
    control = [phoneNumber, userName, userName, targetDate]
    with open("csvFile", "r") as inFile:
        reader = csv.reader(inFile)
        for row in reader:
            for op, item in zip(control, row):
                op(item)
    

    I note that this only works if the csv file has constant interpretation per element, but if it has variant interpretation then a csv file is the wrong storage method. I also note that you’d need some other control object to generate the rest of the sentence; this is left as an exercise for the reader. 🙂

    This allows you to have a library of interpreter functions that can be assigned to fields in the csv file by simply changing the control string. A new control string would invoke a different order of field interpretations with no need to change the source code, and the new string could be entered on command line, stored in the first line of the csv file, or brought in some other way.

    edit: And noting your addendum on using a web interface to configure, that would be a straight-forward way to provide a new control list.

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

Sidebar

Related Questions

I'm working on a project in Python with MySQLdb. As part of this, I'm
I'm using Python/Django, but this is more about the data model and how I
I consider myself a very beginner at python(and programming in general!), but I am
i'm not particularly new at python but i just thought there might be a
This is I guess a question in a few parts. I'm working through the
Working with python interactively, it's sometimes necessary to display a result which is some
I've been working with python for a while now and am just starting to
I have recently been working with Python using Komodo Edit and other simpler editors
I'm working on a Python library that interfaces with a web service API. Like
I'm working on a Python package named lehmer that includes a bunch of extension

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.