Group data using awk

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

Group data using awk


I liked your link on 'awk and sed'.

My file looks like this: (It is a tab separated file with three columns).

ID i ii
1 1 2
1 2 4
1 3 6
2 4 8
2 5 10
3 6 12
3 7 14
3 8 16
3 9 18
4 10 20
5 11 22
5 12 24

I want to group data in such a way that generation of each file should not contain more than 3 ID's. I have wrote a python script and it's working but the file is too huge, so it is taking a lot of time.

I have tried using awk commands but cannot figure it out. Is it also possible to check the size of the file while its generating, I mean, when the file size reaches a certain limit, it should start creating another file.

Thank You!
Reply | Threaded
Open this post in threaded view

Re: Group data using awk

How do you want the output to look like? Also please show the awk command that you have tried?