[highlight=c#]
namespace CSV_List
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//dataGridView1.ColumnCount = 3;
//List<string> _names = new List<string>();
// _names.Add("X");_names.Add("Y");_names.Add("Z");
List<int[]> testParse = parseCSV("Mappe1.csv");
DataTable newTable = new DataTable();
// spalte einfügen
foreach (int column in testParse[0])
{
newTable.Columns.Add();
}
// Zeilen einfügen
foreach (int[] row in testParse)
{
newTable.Rows.Add(row);
}
// dataGridView1.DataSource = newTable;
DataColumn[] colArr0 = new DataColumn[3];
DataColumn[] colArr1 = new DataColumn[3];
DataColumn[] colArr2 = new DataColumn[3];
}
// csv Datei in einem List Speichern
public List<int []> parseCSV(string path)
{
// List objekt Deklarieren
List<int[]> parsedData = new List<int[]>();
using (StreamReader readFile = new StreamReader(path))
{
string line;
string[] row;
while ((line = readFile.ReadLine()) != null)
{
row = line.Split(';');
int[] temp = new int[row.Length];
for (int i = 0; i < row.Length; i++)
{temp[i]=int.Parse(row[i]);
}
parsedData.Add(temp);
}
}
return parsedData;
}
}
[/highlight]
habe ich daten von csv Datei gespeichrért wie Kann ich auf die Daten von jede Spalte zugreifen um ein graph darszustellen
Danke vorraus
namespace CSV_List
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//dataGridView1.ColumnCount = 3;
//List<string> _names = new List<string>();
// _names.Add("X");_names.Add("Y");_names.Add("Z");
List<int[]> testParse = parseCSV("Mappe1.csv");
DataTable newTable = new DataTable();
// spalte einfügen
foreach (int column in testParse[0])
{
newTable.Columns.Add();
}
// Zeilen einfügen
foreach (int[] row in testParse)
{
newTable.Rows.Add(row);
}
// dataGridView1.DataSource = newTable;
DataColumn[] colArr0 = new DataColumn[3];
DataColumn[] colArr1 = new DataColumn[3];
DataColumn[] colArr2 = new DataColumn[3];
}
// csv Datei in einem List Speichern
public List<int []> parseCSV(string path)
{
// List objekt Deklarieren
List<int[]> parsedData = new List<int[]>();
using (StreamReader readFile = new StreamReader(path))
{
string line;
string[] row;
while ((line = readFile.ReadLine()) != null)
{
row = line.Split(';');
int[] temp = new int[row.Length];
for (int i = 0; i < row.Length; i++)
{temp[i]=int.Parse(row[i]);
}
parsedData.Add(temp);
}
}
return parsedData;
}
}
[/highlight]
habe ich daten von csv Datei gespeichrért wie Kann ich auf die Daten von jede Spalte zugreifen um ein graph darszustellen
Danke vorraus
Comment