Suppose I have two text files in.txt
and out.txt
.
in.txt
:
abc one 2 3 4
two 3 4 two twenty
three 3 20 8
adbc two 4 28 3 thirty
How can I read line-by-line and operate when necessary? So that on any line I can check if it has some text in the first column ("abc" and "adbc" in this example), what's in the second column, third column, etc. until that line ends? Then, based on those operations write into out.txt
?
For example, if any line has its 6th column (if it has a 6th column) and it says "twenty" then print to out.txt
"Hello."
or
If the second column is "three" add the following three numbers...