LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   [Noob] Merging line of a file for consolidation... (https://www.linuxquestions.org/questions/linux-newbie-8/%5Bnoob%5D-merging-line-of-a-file-for-consolidation-905255/)

dzounar 09-27-2011 11:39 AM

[Noob] Merging line of a file for consolidation...
 
Hi there,

I was wondering if somebody has already got this tricky one. I'm trying to consolidate a huge CSV file with a lot of values so server comparison. This file is similar to the example below:

server1;0;0;0;1;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0

server2;0;1;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0

server2;0;0;0;0;0;1;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0

server3;0;0;0;1;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0

server3;0;0;0;0;0;0;0;0;0;0;0;1;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0

server3;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;1;0;0;0;0;0;0;0;0;0;0;0;0

server4;0;0;0;1;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0


As you can see, in server2 example, I need to merge all the occurrences of it replacing all zero values with a non zero value where applicable.

Not sure if I made myself clear. Any clues?

grail 09-27-2011 12:46 PM

ummmm .. huh?? Is the idea that once you have run something over this file each server will only have a single entry where all the '1' values should prevail over a '0'?

anomie 09-27-2011 12:56 PM

I think OP is saying he wants to do a bitwise OR on a per-colum basis (for matching server #s). So:
Code:

server5;0;0;1;0
server5;1;1;1;0

Would compute to:
Code:

server5;1;1;1;0
Sounds like homework.


All times are GMT -5. The time now is 08:23 AM.