<?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[array]]></title><description><![CDATA[<p>Hallo zusammen,<br />
ICh möchte eine .csv datei einlesen und eine Zahl aus der 2ten Spalte finden. Also die datei hat 8 Spalten also 7 Semikolon und ich will die eingegebene Zahl in der 2ten Spalte finden. Kann mir einer sagen wie ich die datei dann so in Array aufspliten kann??</p>
<p>THX</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/321168/array</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Jul 2026 01:25:42 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/321168.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 26 Oct 2013 11:18:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to array on Sat, 26 Oct 2013 11:18:49 GMT]]></title><description><![CDATA[<p>Hallo zusammen,<br />
ICh möchte eine .csv datei einlesen und eine Zahl aus der 2ten Spalte finden. Also die datei hat 8 Spalten also 7 Semikolon und ich will die eingegebene Zahl in der 2ten Spalte finden. Kann mir einer sagen wie ich die datei dann so in Array aufspliten kann??</p>
<p>THX</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363060</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363060</guid><dc:creator><![CDATA[guguli]]></dc:creator><pubDate>Sat, 26 Oct 2013 11:18:49 GMT</pubDate></item><item><title><![CDATA[Reply to array on Sat, 26 Oct 2013 11:33:48 GMT]]></title><description><![CDATA[<pre><code>std::ifstream stream(&quot;Datei.txt&quot;); // Datei öffnen
// Alle Checks übersprungen:
stream.ignore( std::numeric_limits&lt;std::streamsize&gt;::max(), ';' ); // Die erste Spalte mitsamt Delimiter überspringen
int a; // Entsprechenden Typ angeben
stream &gt;&gt; a;
</code></pre>
<p>(Ungetestet)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363063</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363063</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Sat, 26 Oct 2013 11:33:48 GMT</pubDate></item><item><title><![CDATA[Reply to array on Sun, 27 Oct 2013 09:21:37 GMT]]></title><description><![CDATA[<p>HI, ich hab das folgend gelöst:</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &lt;vector&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;sstream&gt;
#include &lt;algorithm&gt;
#include &lt;iterator&gt;
#include &lt;fstream&gt;
#include &lt;sstream&gt;
using namespace std;

template&lt;class T&gt; std::string toString(const T&amp; t)
{
	std::ostringstream stream;
	stream &lt;&lt; t;
	return stream.str();
}

template&lt;class T&gt; T fromString(const std::string&amp; s)
{
	std::istringstream stream (s);
	T t;
	stream &gt;&gt; t;
	return t;
}

vector&lt;string&gt; &amp;split(const string &amp;s, char delim, vector&lt;string&gt; &amp;elems) {
	stringstream ss(s);
	string item;
	while (getline(ss, item, delim)) {
		elems.push_back(item);
	}
	return elems;
}

vector&lt;string&gt; split(string s, char delim) {
	vector&lt;string&gt; elems;
	split(s, delim, elems);
	return elems;
}

vector&lt;string&gt; readData(const string &amp;path)
{
	std::vector&lt;std::string&gt; lines;
	ifstream fin(path);
	std::string line;
	while(getline(fin, line))
	{
		lines.push_back(line);
	}
	return lines;
}
bool searchValue(vector&lt;string&gt; data, int column, string value, vector&lt;string&gt; &amp;row)
{
	for(unsigned int i=1; i&lt;data.size();i++)
	{
		row = split(data[i],';');
		string tc = row[column-1];
		if(tc.compare(value)==0)
			return true;
	}
	return false;
}
string replace(string str, char c, char newc)
{
	for(unsigned int i=0;i&lt;str.size();i++)
	{
		if(str[i] == c)
			str[i] = newc;
	}
	return str;
}
double sumUpRow(vector&lt;string&gt; row)
{
	double result = 0;
	for(unsigned int i=2; i&lt;row.size();i++)
	{
		string value = row[i];
		string newValue = replace(value,',','.');
		result += fromString&lt;double&gt;(newValue);

	}
	return result;
}
int _tmain(int argc, _TCHAR* argv[])
{
	vector&lt;string&gt; data = readData(&quot;data.csv&quot;);
	vector&lt;string&gt;* row = new vector&lt;string&gt;();

	string number = &quot;&quot;;
	while(number[0] != 'e')
	{
		cout &lt;&lt; &quot;Suche nach T[C]: &quot;;
		cin &gt;&gt; number;
		bool wasfound = searchValue(data,2,number, *row);
		if(wasfound == true)
		{
			double result = sumUpRow(*row);
			cout &lt;&lt; &quot;Ergebnis von T[C]:&quot; &lt;&lt; result &lt;&lt; endl;
		}
		else
			cout &lt;&lt; &quot;T[C] nicht gefunden &quot; &lt;&lt; endl;
	}
	return 0;
}
</code></pre>
<p>nun möchte an der Stelle</p>
<pre><code>cout &lt;&lt; &quot;T[C] nicht gefunden &quot; &lt;&lt; endl;
</code></pre>
<p>so machen dass die vorherige und nächste zeile betrachtet werden.<br />
Bsp. die zahl 217 existiert nicht. aber die Zahlen 216 und 218 existieren.<br />
Also die datei sieht ungefähr so aus:<br />
218;0.34;2.435;2.349<br />
216;0.12;0.234;1.45<br />
Nun möchte ich diese beide Zahlen linear interpolieren.<br />
Kann mir einer dabei helfen???</p>
<p>THX</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363254</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363254</guid><dc:creator><![CDATA[guguli]]></dc:creator><pubDate>Sun, 27 Oct 2013 09:21:37 GMT</pubDate></item></channel></rss>