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

The Archive Base Latest Questions

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

Requirements : I have a Python project which parses data feeds from multiple sources

  • 0

Requirements:
I have a Python project which parses data feeds from multiple sources in varying formats (Atom, valid XML, invalid XML, CSV, almost-garbage, etc…) and inserts the resulting data into a database. The catch is the information required to parse each of the feeds must also be stored in the database.

Current solution:
My previous solution was to store small python scripts which are evaled on the raw data, and return a data object for the parsed data. I’d really like to get away from this method as it obviously opens up a nasty security hole.

Ideal solution:
What I’m looking for is what I would describe as a template-driven feed parser for Python, so that I can write a template file for each of the feed formats, and this template file would be used to make sense of the various data formats.

I’ve had limited success finding something like this in the past, and was hoping someone may have a good suggestion.

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

    Instead of evaling scripts, maybe you should consider making a package of them?
    Parsing CSV is one thing — the format is simple and regular, parsing XML requires completely another approach. Considering you don’t want to write every single parser from scratch, why not just write a bunch of small modules, each having identical API and use them? I believe, using Python itself (not some templating DSL) is ideal for this sort of thing.

    For example, this is an approach I’ve seen in one small torrent-fetching script I’m using:

    Main program:

    ...
    def import_plugin(name):
        mod = __import__(name)
        components = name.split('.')
        for comp in components[1:]:
            mod = getattr(mod, comp)
        return mod
    
    ...
    feed_parser = import_plugin('parsers.%s' % feed['format'])
    data = feed_parser(...)
    ...
    

    parsers/csv.py:

    #!/usr/bin/python
    from __future__ import absolute_import
    
    import urllib2
    import csv
    
    def parse_feed(...):
        ...
    

    If you don’t particularly like dynamically loaded modules, you may consider writing, for example, a single module with several parses classes (probably derived from some “abstract parser” base class).

    class BaseParser(object):
        ...
    
    class CSVParser(BaseParser):
        ...
    register_feed_parser(CSVParser, ['text/plain', 'text/csv'])
    ...
    
    parsers = get_registered_feed_parsers(feed['mime_type'])
    data = None
    for parser in parsers:
        try:
            data = parser(feed['data'])
            if data is not None: break
        except ParsingError:
            pass
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 229k
  • Answers 229k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer As far as I can tell, there is no way… May 13, 2026 at 1:50 am
  • Editorial Team
    Editorial Team added an answer If you need weak entropy on Linux, why not read… May 13, 2026 at 1:50 am
  • Editorial Team
    Editorial Team added an answer There are lots of ways of doing this without using… May 13, 2026 at 1:50 am

Related Questions

I have an idea for a hobby project which performs some code analysis and
I have a list of requirements for a software project, assembled from the remains
In our environment, we share resources across multiple projects and platforms. When building for
I'm working on a project which needs an embedded DSL to fullfill its expected

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.