samedi 20 janvier 2018

Shuffling text from file by group of data

I was looking for some approach in Python / Unix Command to shuffle large data set of text by grouping based on first words value like below-

Input Text:

"ABC", 21, 15, 45
"DEF", 35, 3, 35
"DEF", 124, 33, 5
"QQQ" , 43, 54, 35
"XZZ", 43, 35 , 32
"XZZ", 45 , 35, 32

So it would be randomly shuffled but keep the group together like below

Output Sample-

"QQQ" , 43, 54, 35  
"XZZ", 43, 35 , 32
"XZZ", 45 , 35, 32  
"ABC", 21, 15, 45
"DEF", 35, 3, 35
"DEF", 124, 33, 5

I found solution by normal shuffling, but I am not getting the idea to keep the group while shuffling.




Aucun commentaire:

Enregistrer un commentaire