Unix & Linux Asked by LiNi on February 21, 2021
I have comma separated file:
ID,Disease,Status
Sample1,Disease1,High
Sample1,Disease2,Low
Sample1,Disease3,Medium
Sample2,Disease1,Low
Sample2,Disease2,Medium
Sample2,Disease3,Low
The first field is the ID number, the second field is the name of the disease and the third column is the risk status of the individual for that disease. I need to have all diseases in rows and IDs in column. Each ID should have be allotted one row with all disease risk status mentioned column wise. So, the output should be:
Expected Output file:
ID,Disease1,Disease2,Disease3
Sample1,High,Low,Medium
Sample2,Low,Medium,Low
apt install rs
echo -e "1,2n3,4" | rs -c',' -C',' -T
1,3,
2,4,
There are many ways to transpose data for every language and even a few dedicated tools;
https://stackoverflow.com/questions/1729824/an-efficient-way-to-transpose-a-file-in-bash
Answered by user1133275 on February 21, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP