TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Hesham Hassanein
NA
140
17k
deleting empty spaces from csv file in visual studio
Sep 10 2014 9:13 AM
Hello this method is generating a .csv file but with blank lines after the sequence, what i need to do is to delete these blank
Below is the code.
Thanks in advance
static void GenerateCsv(DataTable dt, string device, string Menutree, string EndNote, double Länge, double Breite, string PicturePath)
{
string ProgramPfad = (@"C:\Robotron\MobileRobotDaten\" + device + "_" + Menutree + "_" + EndNote + ".csv");
using (System.IO.StreamWriter file = new System.IO.StreamWriter(ProgramPfad))
{
file.WriteLine("PROJECT;SEQUENCE;STEP;XPOS;YPOS;ZPOS;WRIST;WRISTROT;SPEED;PAUSE");
int a = 1;
int b = 1;
string[] buffer = new string[dt.Rows.Count];
for (int i = 0; i < (3 * dt.Rows.Count); i++)
{
string end = dt.Rows[i].ItemArray[0].ToString();
string Prozent = dt.Rows[i].ItemArray[1].ToString();
if (!end.Contains("End"))
{
Prozent = Calculate(Prozent, Länge, Breite);
}
if (end.Contains(EndNote))
{
foreach (string strg in buffer)
{
file.WriteLine(strg);
}
/* Picture Path*/
// file.WriteLine(PicturePath);
break;
}
/* Anpassen Z*/
buffer[b - 1] = (device + ";" + a + ";" + 1 + ";" + Prozent + ";" + "3" + ";" + 71 + ";" + -51 + ";" + 40 + ";" + 400);
b++;
/* Anpassen Z*/
buffer[b - 1] = (device + ";" + a + ";" + 2 + ";" + Prozent + ";" + "1,1" + ";" + 71 + ";" + -51 + ";" + 10);
b++;
/* Anpassen Z*/
buffer[b - 1] = (device + ";" + a + ";" + 3 + ";" + Prozent + ";" + "3" + ";" + 71 + ";" + -51 + ";" + 25 + ";" + 100);
a++;
b++;
if (end.Contains("End"))
{
Array.Clear(buffer, 0, buffer.Length);
a = 1;
b = 1;
}
}
}
}
Reply
Answers (
0
)
Integers
Datatable to XML in C#