troubleshooting Question

Replace the Field in a txt File

Avatar of SaraDob
SaraDob asked on
.NET Programming
2 Comments1 Solution60 ViewsLast Modified:
New to programming. Begging your patience here.

Im  trying to parse a txt file . The text file  is a comma delimited file and the fields are enclosed in quotes.
The file has rows of data like this.

"CareType" ,"Company" ,"CareNumber", "HomeCare","ABCComapny","WC3456","lastName","Hollman"

The "keys" will always remain the same, throughout the file, only values change,And the keys are fixed in position.

Im trying to eliminate the "keys" and just retain the values like:

Im using TextFieldParser to read through the fields.
I want to loop through the FieldRows and simply delete the "Key" fields and save the .txt file.

Right now i'm having this code:

using (TextFieldParser parser = new TextFieldParser(filename.FullName))
                                   parser.Delimiters = new string[] { "," };
                                parser.HasFieldsEnclosedInQuotes = true;
                               while (!parser.EndOfData)
                                        string[] FieldRow = parser.ReadFields();
                                                          //int Rowlength=FieldRow.Length;
                                                        if (FieldRow[0]=="CareType")
                                                             // I want to Replace the key with null or simply delete here.
                                                            //save the .txt file here.
                                                               I cant use FieldRow[0].Replace("careType","");

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros