i would like to remove the double quotes from my below text file. i need to input the file using my C# application and read the text file and then remove all the double quotes and give the output. I need to remove all the quotes and make them into perfect four spaced format So how can i do this.
Input file
Designator Comment Footprint Center-X(mm) Center-Y(mm)
"C5" "CAP,1n,50V.0603" "CAPC1608N" "97.733" "73.025"
"C4" "CAP,1n,50V.0603" "CAPC1608N" "99.638" "73.025"
"C3" "CAP,1n,50V.0603" "CAPC1608N" "101.543" "73.025"
"C7" "CAP1233,,1n,50V.0603" "CAPC1608N" "103.448" "73.025"
"C8" "CAP1233,1n,50V.0603" "CAPC1608N" "105.353" "73.025"
"C9" "CAP455,1n,50V.0603" "CAPC1608N" "107.258" "73.025"
"C10" "CAP4522,1n,50V.0603" "CAPC1608N" "109.163" "73.025"
My codes from my C# application to input the text file:
private void convert_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = @"C:\files";
ofd.Filter = "TXT files (*.txt)|*.txt";
ofd.FilterIndex = 2;
ofd.RestoreDirectory = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
int[] cols = new int[] { 15, 30, 15, 20, 12 };
string[] strLines = System.IO.File.ReadAllLines(fileName);
StringBuilder sb = new StringBuilder();
string line = string.Empty;
for (int i = 0; i < strLines.Length; i++)
{
line = RemoveWhiteSpace(strLines[i]).Trim(); // here i am getting error in RemoveWhiteSpace, that it is not in the context
string[] cells = line.Replace("\"", "").Split(new string[] { " " }, StringSplitOptions.None);
for (int c = 0; c < cells.Length; c++)
sb.Append(cells[c].PadRight(cols[c]));
sb.Append("\r\n");
}
//System.IO.File.WriteAllText(fileName, sb.ToString());
MessageBox.Show(sb.ToString());
}
}
How can i do this? Please help me out.
I would like to get the format in below style for all the text file i input. So for the above text file i would like to get the format as shown below
Designator Comment Footprint Center-X(mm) Center-Y(mm)
C5 CAP,1n,50V.0603 CAPC1608N 97.733 73.025
C4 CAP,1n,50V.0603 CAPC1608N 99.638 73.025
C3 CAP,1n,50V.0603 CAPC1608N 101.543 73.025
C7 CAP,1n,50V.0603 CAPC1608N 103.448 73.025
C8 CAP,1n,50V.0603 CAPC1608N 105.353 73.025
C9 CAP,1n,50V.0603 CAPC1608N 107.258 73.025
C10 CAP,1n,50V.0603 CAPC1608N 109.163 73.025