1,105,578 Community Members

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

Member Avatar
Sunshineserene
Junior Poster
187 posts since Jul 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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?

Member Avatar
Sunshineserene
Junior Poster
187 posts since Jul 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
NormR1
Posting Sage
7,723 posts since Jun 2010
Reputation Points: 563 [?]
Q&As Helped to Solve: 793 [?]
Skill Endorsements: 16 [?]
Team Colleague
 
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.

Question Answered as of 3 Years Ago by NormR1
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: