php - Get remote text file, process, and update database - approach and scripting language to use? -


I have to do some basic feed processing, so get a file through FTP, process it (i.e. those fields About what I care about), and then update the local database. And similarly the other direction: Get data from DB, create a file, and upload via FTP the script will be called by the cron.

I think that this idea will be for each type of feed, define the FTP connection / file information, then there should be a translation of that the data field in the file belongs to the data fields, Which can work with the application (and course process of this process). Additionally, write different scripts that do common entry functions for different objects that can be used in different feeds.

As an e-commerce example, to say that I work with different suppliers who provide feed for me feeds variant (object) type: product, category, or order There may be information. For each type of feed I clearly work with different areas and call different updates or scripts.

What is the best language to implement in this? I can work with PHP, but I'm looking for a project to start learning Pearl or Python, so it can be good for me as well.

If Pearl or Python, you can briefly implement a higher level then how to separate different scripts, object-oriented approach, implementing new feeds or processing tasks in the future is easy , e.t.c. [Full disclosure: The class I wrote in PHP already used to create a new feed I had already done my job, but it was very messy and difficult to do. So this question is "help me to do my job", but a 'best way' for your development is not the type of question.]

Thank you!

The "best" language is very personal, while learning Python generally is easy and easy to read Pearl is often referred to as the "writing-only" language in jokes, on the other hand, Pearl is used extensively for network management. Python is used more for system management or programming, both of which are areas of excellence, and those areas where they do not work.

Either language will allow you to solve your problem easily. Both have all the necessary modules that are either bundled libraries or are easily available.

If I was using Python then I would use the ConfigParser

Settings for each project, ftplib:

To talk to the FTP server, and for example one of the many database libraries, assuming you're using postgrads:

< P> Finally I will use the excellent option parser module for command line options that comes with Python:

A code From the perspective I will have the following objects:

  # reads in a config file, it determines which feed is used, and any of these commands are imported and Receive data in the class given below for an export class in a valid format class from FeedManager # DB. DbImport # Keep data in DBExport DBExport from a valid format class # Data from FTP in a valid format class Of The FtpImport # Keep FTP data from Vamanik format class FtpExport  

Each class translates to a canonical format, which can be one of the other complementary sections.

The config file may look like this:

  [GetVitalStats] SourceUrl = ftp.myhost.com SourceType = FTP destination = host = mydbserver; Database = amedab ​​sorotype = postgrass  

and finally, you call it this way:

  process_feed.py --feed = GetVitalStats  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -