Hesham Hassanein

Hesham Hassanein

  • NA
  • 140
  • 17.1k

writing data into csv file

Oct 2 2014 9:38 AM
I have read references for writing data into csv file but my problem is that i wan to read data from another 2 files and select two specific elements (one from each file and then write them into the new file). Here is what i came to
 The file is not generated and I want to know how can i get the y as the element in the other csv line
 
This is reading two csv files and generating a new one but i want to select the x from the first csv file and y from the second csv file.
static void LeftBottom(int MobileID)
{
string ProgramPfad = (@"C:\Robotron\Execution\"+MobileID+".csv");
int b = 2;
string linee;
List<string> x= new List<string>();
List<string> y = new List<string>();

int z = 25;
StreamReader reader = File.OpenText(@"C:\Robotron\Execution\TS_Right_Bottom.csv");
StreamReader rdr = File.OpenText(@"C:\Robotron\Execution\TS_Left_Top.csv");
while ((linee = reader.ReadLine()) != null)
{
string[] fields = linee.Split('\t');
if (fields.Length != 15) continue;
int Keyid = Convert.ToInt32(fields[0]);
int id = Convert.ToInt32(fields[1]);
if (id == MobileID)
{
x.Add(fields[5]);
y.Add(fields[6]);
break;
}


using (System.IO.StreamWriter file = new System.IO.StreamWriter(ProgramPfad))
{
file.WriteLine("intMobileID;strTasten_Name;strTastenfunktion;strDruckrichtung;dblX_Wert;dblY_Wert;dblZ_Wert;dbldX_Wert;dbldY_Wert;dbldZ_Wert;intTastendruck;intDauer;intAnzahl;strBewegungstyp");
string[] buffer = new string[1];
buffer[b - 1] = (Keyid+";"+MobileID+";"+"TS_Left_Bottom"+";"+";"+"mitte"+";"+ x+";"+y +";"+z+";"+0+";"+0+";"+0+";"+12000+";"+100+";"+1+";"+"XY-Z");
}
}

Answers (26)