private void processFile(string source, string output, char delimiter)
{
int counter = 0;
var lines = File.ReadAllLines(@source);
string[] headers = lines[0].Split(delimiter).Select(x => x.Trim('\"')).ToArray();
var xmlOut =
new XElement("Import",
new XElement("Archive",
new XElement("Document","",new XAttribute("Pass","true"),
new XElement("DocFile",new XAttribute("FileLoc",@"X:\MyFile.pdf"),
// BEGIN THE PARSING
new XElement("Fields",
lines.Where((line, index) => index > 0).Select(line =>
line.Split(delimiter).Select((column, index) => new XElement("Field", new XAttribute("value", column), new XAttribute("pass", "true"), new XAttribute("confidence", "0"), new XAttribute("Name", headers[index]))))))
)));
counter++;
xmlOut.Save(@output + @"\Output-"+ counter + ".xml");
}
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE