954,554 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to extract columns/rows of values from a text file?

I have a text file in this format:

AUGC
U1212
A2121
G3434
C4343

I need to extract the number that I need depending on which variables (letters) I'm comparing. For example, I need the value for A and U, so the value I need to look up for or extract is 1. For C and C, I will need to extract 3, and so on and so forth. I need a program that can look up this table automatically and extract what I need. May I know how do I do that?

Sunshineserene
Junior Poster
187 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

Sorry, the first row, AUGC should be directly above the numbers 1212. There is some posting error. So the top right hand corner is actually a blank.

Sunshineserene
Junior Poster
187 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

Say a row = a line and a column a word on that line.
Create a 2 dim array with first dim >= number of lines in file
Read in file and parse words of each line into an array and add that array to the first array at its line number.
Now you can get the contents of each row and column by indexing the 2 dim array.

NormR1
Posting Expert
Moderator
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: