Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Given a text file file.txt
, transpose its content.
You may assume that each row has the same number of columns, and each field is separated by the ' '
character.
Example:
If file.txt
has the following content:
name age
alice 21
ryan 30
Output the following:
name alice ryan
age 21 30
awk '
{
for (i = 1; i <= NF; i++) {
if(NR == 1) {
s[i] = $i;
} else {
s[i] = s[i] " " $i;
}
}
}
END {
for (i = 1; s[i] != ""; i++) {
print s[i];
}
}' file.txt
In our experience, we suggest you solve this Transpose File LeetCode Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
If you are stuck anywhere between any coding problem, just visit Queslers to get the Transpose File LeetCode Solution
I hope this Transpose File LeetCode Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More Coding Solutions >>