I have two INI files, and I want see the differences between then (which keys have different values, and which keys one has that the other don't), so...
How-to compare two (or more) INI files?
Here is an answer from serverfault.
https://serverfault.com/questions/28194/is-there-a-tool-to-compare-values-in-ini-files
Or have a look at this list of Ini editors/compare tools, though a differencing tool would be the easiest probably
You may use a comparison tool for that, like Winmerge, an open source and free differencing tool for Windows. It shows the two files side-by-side, colormarking the differences.
Supports Microsoft Windows 98/2000/XP/2003/Vista/7.
I've been using Beyond Compare by Scootersoftware for over 10 years now. http://www.scootersoftware.com/
Use file compare command-line utility (in any windows) from the command prompt (enter cmd intor start/run dialog)
fc inifile1.ini inifile2.ini
The result will be typed aftewards. If you would like to review the results
fc inifile1.ini inifile2.ini > results.txt
After the latter you will see the report in the file results.txt
I found a lovelly windows freeware utility called ExamDiff the other day that will do exactly what you want, is user friendly and free. It will even do directory comparisons if you pay for the 'pro' version.
I'm using this service http://inicompare.io/
Compares more than two.
For the reason I didnt found what I was looking for, here my quick and dirty python solution, maybe it helps someone:
import configparser as cp
f1 = "org.ini"
f2 = "new.ini"
config1 = cp.ConfigParser()
config2 = cp.ConfigParser()
config1.read(f1)
config2.read(f2)
for section in config1.sections():
if section not in config2.sections():
print(section, "NOT in 2")
else:
for key in config1[section]:
if key not in config2[section]:
print("[miss] section", section, "key", key, "not in new")
else:
if config1[section].get(key).split(";")[0].strip() != config2[section].get(key).split(";")[0].strip():
print("[chang] section", section, "key", key, config1[section].get(key).split(";")[0].strip(),
"org != new", config2[section].get(key).split(";")[0].strip())
for section in config2.sections():
if section not in config1.sections():
print(section, "NOT in 1")
else:
for key in config2[section]:
if key not in config1[section]:
print("[miss] section", section, "key", key, "not in org")
To compare 3 files, you can use a VimDiff, e.g.
vimdiff file1.ini file2.ini file3.ini
For GUI tools, check:
I actually wrote a CLI app to deal with this problem when I was dealing with it in the workplace, and my employer was kind enough to let me open source it:
https://github.com/Comcast/compare-ini-files
This will compare 2 or more ini files, and report back on values that are different, and stanzas that are missing.
This is a newer version of this http://winmerge.org/source-code/ which someone has posted here in this thread.