<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[comaprision of the file values]]></title><description><![CDATA[<p dir="auto">Hi All,</p>
<p dir="auto">I have one file of format like this (file1.txt):<br />
s1=ABCDE<br />
s2=ERTY 1<br />
s3=PRTYU 2<br />
This implies that value of s1 is ABCDE, value of s2 is ERTY 2 and like this.</p>
<p dir="auto">I have another file (file2.txt):<br />
s2=EEEE<br />
s1=ABCD23</p>
<p dir="auto">Requirement is to compare the value of s1 of file2 with s1 of file1 and so on..... and to display that values are same or not.</p>
<p dir="auto">Kindly suggest how this can be achieved...</p>
<p dir="auto">Regards,<br />
Anuj</p>
]]></description><link>https://forum.qt.io/topic/88129/comaprision-of-the-file-values</link><generator>RSS for Node</generator><lastBuildDate>Wed, 17 Jun 2026 22:59:56 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/88129.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 26 Feb 2018 09:48:35 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to comaprision of the file values on Mon, 26 Feb 2018 11:48:58 GMT]]></title><description><![CDATA[<p dir="auto">Just to demonstrate what <a class="plugin-mentions-user plugin-mentions-a" href="/user/johansolo">@<bdi>JohanSolo</bdi></a> and <a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> suggested:</p>
<pre><code>    const QSettings file1("file1.txt", QSettings::IniFormat);
    qDebug() &lt;&lt; "file1 keys" &lt;&lt; file1.allKeys();

    const QSettings file2("file2.txt", QSettings::IniFormat);
    qDebug() &lt;&lt; "file2 keys" &lt;&lt; file2.allKeys();

    foreach (const QString &amp;key, file1.allKeys()) {
        if (!file2.contains(key))
            qDebug() &lt;&lt; "in file1 only:" &lt;&lt; key;
    }

    foreach (const QString &amp;key, file2.allKeys()) {
        if (!file1.contains(key))
            qDebug() &lt;&lt; "in file2 only:" &lt;&lt; key;
    }

    foreach (const QString &amp;key, file1.allKeys()) {
        if ((file2.contains(key)) &amp;&amp; (file1.value(key) != file2.value(key)))
            qDebug() &lt;&lt; "file1 and file2 differ:" &lt;&lt; key &lt;&lt; file1.value(key) &lt;&lt; file2.value(key);
    }
</code></pre>
<p dir="auto">Output (with your sample files above):</p>
<pre><code>file1 keys ("s1", "s2", "s3")
file2 keys ("s1", "s2")
in file1 only: "s3"
file1 and file2 differ: "s1" QVariant(QString, "ABCDE") QVariant(QString, "ABCD23")
file1 and file2 differ: "s2" QVariant(QString, "ERTY 1") QVariant(QString, "EEEE")
</code></pre>
<p dir="auto">Cheers.</p>
]]></description><link>https://forum.qt.io/post/443959</link><guid isPermaLink="true">https://forum.qt.io/post/443959</guid><dc:creator><![CDATA[Paul Colby]]></dc:creator><pubDate>Mon, 26 Feb 2018 11:48:58 GMT</pubDate></item><item><title><![CDATA[Reply to comaprision of the file values on Mon, 26 Feb 2018 10:13:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/anuj-nogja">@<bdi>anuj-nogja</bdi></a> With ini parser <a class="plugin-mentions-user plugin-mentions-a" href="/user/johansolo">@<bdi>JohanSolo</bdi></a> means QSettings class.</p>
]]></description><link>https://forum.qt.io/post/443934</link><guid isPermaLink="true">https://forum.qt.io/post/443934</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Mon, 26 Feb 2018 10:13:11 GMT</pubDate></item><item><title><![CDATA[Reply to comaprision of the file values on Mon, 26 Feb 2018 09:57:32 GMT]]></title><description><![CDATA[<p dir="auto">Your files looks much like INI files actually. If so, use a INI parser and check if the key "s1" of file one matches the "s1" key in file2.</p>
<p dir="auto">If your files are not compatible with INI format, just implement your own parsing method. I'd store each key=value entry in a QMap. Then it's simply a matter of checking the value of "s1" key in both QMap instances. Note that this method also applies to real INI files.</p>
]]></description><link>https://forum.qt.io/post/443928</link><guid isPermaLink="true">https://forum.qt.io/post/443928</guid><dc:creator><![CDATA[JohanSolo]]></dc:creator><pubDate>Mon, 26 Feb 2018 09:57:32 GMT</pubDate></item></channel></rss>