One input file to multiple output files
Posted
by
user1265669
on Stack Overflow
See other posts from Stack Overflow
or by user1265669
Published on 2012-11-11T22:48:35Z
Indexed on
2012/11/11
22:59 UTC
Read the original article
Hit count: 88
python
I found some helpful stuff on this site but my input file is different from the examples already posted and I cannot make the leap in an efficient manner.
My input file looks like this:
sample_dude data1 data2 data3 data4
sample_lady data5 data6 data7 data8
sample_dude data9 data10 data11 data12
sample_child data13 data14 data15 data16
I want to create a separate file for each sample with all the data columns. For example, one file would be called sample_dude.txt and look like this:
data1 data2 data3 data4
data9 data10 data11 data12
There is an unknown number of samples but always just four data columns.
Any help greatly appreciated. Thank you.
PS: I'm trying to do this in python.
© Stack Overflow or respective owner