<?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[QFile read only lines containing specific search term]]></title><description><![CDATA[<p dir="auto">Hello!</p>
<p dir="auto">When i open a file to read all i want to select specific rows "to be saved" as an output to QStringList.<br />
So when i read through a file and a line has ex. "orange" i want to save that line to a list.</p>
<p dir="auto">My read file is a CSV and i have my search terms in a combo box.</p>
]]></description><link>https://forum.qt.io/topic/140537/qfile-read-only-lines-containing-specific-search-term</link><generator>RSS for Node</generator><lastBuildDate>Mon, 14 Sep 2026 23:35:30 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/140537.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 05 Nov 2022 19:31:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QFile read only lines containing specific search term on Wed, 09 Nov 2022 19:31:26 GMT]]></title><description><![CDATA[<p dir="auto">Hello!</p>
<p dir="auto">Yes you are correct.<br />
the setup is like this</p>
<pre><code>    QFile database("/RDS.csv");
    QTextStream fileOutputStream(&amp;database);
    QString lineData;
    QStringList fileOutput;
</code></pre>
<p dir="auto">And my search condition is</p>
<pre><code>QString condition = ui-&gt;comboBox-&gt;currentText();
</code></pre>
<p dir="auto">Also i don't need to hunt the end of line markers.<br />
I had this setup when i was reading all data before.<br />
I wanted to take the first column if the row contained a search term.<br />
But for this it works fine with</p>
<pre><code>fileOutput.append(lineData);
</code></pre>
]]></description><link>https://forum.qt.io/post/735571</link><guid isPermaLink="true">https://forum.qt.io/post/735571</guid><dc:creator><![CDATA[RainyDays]]></dc:creator><pubDate>Wed, 09 Nov 2022 19:31:26 GMT</pubDate></item><item><title><![CDATA[Reply to QFile read only lines containing specific search term on Sat, 05 Nov 2022 23:11:08 GMT]]></title><description><![CDATA[<p dir="auto">I assume the thing named <code>fileOutput</code> is your desired QStringList.<br />
What is the relationship between your input data, presumably <code>database</code>, and the text stream, <code>fileOutputStream</code> presumably a QTextStream,  you are attempting to read from.</p>
<p dir="auto">BTW, the string returned by <a href="https://doc.qt.io/qt-6/qtextstream.html#readLine" target="_blank" rel="noopener noreferrer nofollow ugc">QTextStream::readLine()</a> does not contain any end-of-line markers, so there is not need to try to remove them.</p>
]]></description><link>https://forum.qt.io/post/735159</link><guid isPermaLink="true">https://forum.qt.io/post/735159</guid><dc:creator><![CDATA[ChrisW67]]></dc:creator><pubDate>Sat, 05 Nov 2022 23:11:08 GMT</pubDate></item><item><title><![CDATA[Reply to QFile read only lines containing specific search term on Sat, 05 Nov 2022 20:35:05 GMT]]></title><description><![CDATA[<p dir="auto">Ok, so here is what i came up with :)</p>
<pre><code>  if (database.open(QFile::ReadOnly | QIODevice::Text))
           {
               while(!fileOutputStream.atEnd())
               {
               lineData = fileOutputStream.readLine();
                if (lineData.contains(condition))
                {
                fileOutput.append(lineData.split("\n"));
                }

               }
               database.close();
           }

</code></pre>
]]></description><link>https://forum.qt.io/post/735154</link><guid isPermaLink="true">https://forum.qt.io/post/735154</guid><dc:creator><![CDATA[RainyDays]]></dc:creator><pubDate>Sat, 05 Nov 2022 20:35:05 GMT</pubDate></item><item><title><![CDATA[Reply to QFile read only lines containing specific search term on Sat, 05 Nov 2022 19:55:40 GMT]]></title><description><![CDATA[<p dir="auto">Ok, so the output from the file needs to be limited by the condition.</p>
]]></description><link>https://forum.qt.io/post/735151</link><guid isPermaLink="true">https://forum.qt.io/post/735151</guid><dc:creator><![CDATA[RainyDays]]></dc:creator><pubDate>Sat, 05 Nov 2022 19:55:40 GMT</pubDate></item><item><title><![CDATA[Reply to QFile read only lines containing specific search term on Sat, 05 Nov 2022 19:45:51 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">While reading, no need to load useless data.</p>
]]></description><link>https://forum.qt.io/post/735148</link><guid isPermaLink="true">https://forum.qt.io/post/735148</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sat, 05 Nov 2022 19:45:51 GMT</pubDate></item><item><title><![CDATA[Reply to QFile read only lines containing specific search term on Sat, 05 Nov 2022 19:44:47 GMT]]></title><description><![CDATA[<p dir="auto">Is it easier to do this while reading or when the data is in the list?</p>
]]></description><link>https://forum.qt.io/post/735147</link><guid isPermaLink="true">https://forum.qt.io/post/735147</guid><dc:creator><![CDATA[RainyDays]]></dc:creator><pubDate>Sat, 05 Nov 2022 19:44:47 GMT</pubDate></item><item><title><![CDATA[Reply to QFile read only lines containing specific search term on Sat, 05 Nov 2022 19:33:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rainydays">@<bdi>RainyDays</bdi></a> said in <a href="/post/735145">QFile read only lines containing specific search term</a>:</p>
<blockquote>
<p dir="auto">So when i read through a file and a line has ex. "orange" i want to save that line to a list.</p>
</blockquote>
<p dir="auto">And what's the exact problem you face? Read the line, check for your condition and add the values to your stringlist.</p>
]]></description><link>https://forum.qt.io/post/735146</link><guid isPermaLink="true">https://forum.qt.io/post/735146</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Sat, 05 Nov 2022 19:33:22 GMT</pubDate></item></channel></rss>