473,587 Members | 2,227 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: Looking for a Duo - file comparison and a file parser

du**********@gm ail.com wrote:
HI,

I'm thinking of writing a file comparison utility in python. This
utility will work as:

1. Compare 2 files for the differences. Both files contain some
numerical results.
2. Generate a common file containing the differences (the same way as
'diff' generate an output)
3. Now, I will parse this file containing differences to check as to how
much is the difference of one file from other. So, for this I hope a
parser will be required.

Is there a utility available that performs similar job ( that some one
might have created considering the huge number of users of python) ?

Or may be some one has written some parser?
There are a couple of ways to do #3. One would be to use the difflib module from
the standard library. The Differ.compare( ) method will give you a sequence of
lines with prefixed character saying whether the line was the same in both
files, deleted from the first or added by the second. Lines that are recognized
as having changed (rather than just being deleted then readded with
modifications) are also noted. The parsing you would have to do would be minimal.

http://docs.python.org/dev/library/difflib

Or you could use diff and diffstat:

http://invisible-island.net/diffstat/

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Sep 10 '08 #1
0 904

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2001
by: YoTuco | last post by:
I've been looking for a good wildcard file name parser. That is, some module in Python or something someone has made that can take a file name with the '*' or '?' wildcards in it, parse a list and give back the matches. It seems like a common enough task that one would be around? Or do I just have to roll up my sleeves, dig-in and learn RE?...
0
1913
by: gael.pegliasco | last post by:
Hi, How are you dear and nice helper :) ? I'm trying to test xpath with this simple program : import xml.dom.minidom from xml.xpath.Context import Context import xml.xpath
1
4268
by: Sony Antony | last post by:
We have a situation wherin we should translate the incoming XML based on one schema to the outgoing XML that is based on another schema. Since both input and output are both XML, XSLT was the natural preference. But there was a requirement that demanded a part of the generated XML to be different depending on whether an element was present...
2
1417
by: CJ | last post by:
I've got following: > file_a content needs to be compared with file_b content. I want to write content in binary form, then run a line by line comparison on characters. When the first different character has been found, a modification printf message will print to screen. Any ideas? Or good C-link with sample code you could direct me to?...
4
2381
by: News | last post by:
Hi Everyone, The attached code creates client connections to websphere queue managers and then processes an inquiry against them. The program functions when it gets options from the command line. It also works when pulling the options from a file.
7
10275
by: christian.eickhoff | last post by:
Hi Everyone, I am currently implementing an XercesDOMParser to parse an XML file and to validate this file against its XSD Schema file which are both located on my local HD drive. For this purpose I set the corresponding XercesDOMParser feature as shown in the upcoming subsection of my code. As far as I understand, the parsing process...
3
1479
by: Carroll, Barry | last post by:
Greetings: Please forgive me if this is the wrong place for this post. I couldn't find a more acceptable forum. If there is one, please point me in the right direction. I am part of a small team writing a table-driven automated testing framework for embedded software. The tables, which contain rows of keywords and data that drive the...
28
5768
by: kaferro | last post by:
What is the safest way to make an argv comparison? The code below works. #include <iostream> #include <string> using namespace std; int main(int argc, char *argv) {
3
3542
by: jinendrashankar | last post by:
i am getting following error in my code help me to slove this issue $ gcc -Wall -g -I/usr/include/libxml2/libxml -c create_xml.c In file included from create_xml.c:2: /usr/include/libxml2/libxml/tree.h:20:31: libxml/xmlversion.h: No such file or directory /usr/include/libxml2/libxml/tree.h:880:30: libxml/xmlmemory.h: No such file or...
0
7915
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8205
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7967
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5712
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.