We help IT Professionals succeed at work.
Get Started

C#  Matching an item in a list with the corresponding item in a text file

103 Views
Last Modified: 2015-12-05
Hello experts
C#
I have a List Lnodes with just one item per line: an int value  named "IdNumber"

I have a .txt file with two items per line:
- "IdNumber" (always the same lenght and position)
- a separator (;)
- "Position" (a string item with different length)

I need to read, line by line, the List Lnodes and,  for each value of IdNumber;
             - browse the .txt file
             - find the line that contains the same IdNumber value
             - extract on that line the corresponding "Position" string
             - Add that value to a row on another list

I'v tried a lot of methods (substrings, arrays, and so on) and now I'm lost !!
Hereunder are a sample of Lnodes and another of the .text file


List Lnodes

310
311
312
313
314
....



.txt file
310;UpSpine
311;LeftArm
312;LeftForeArm
313;LeftHand
314;MidSpine
315;RightForeArm
316;RightArm
317;Pelvis
Comment
Watch Question
Retired
CERTIFIED EXPERT
Distinguished Expert 2017
Commented:
This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answer
Why Experts Exchange?

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.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE