LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Filtering the input file with certain rules (https://www.linuxquestions.org/questions/linux-general-1/filtering-the-input-file-with-certain-rules-4175472257/)

sumit.inform 08-05-2013 07:59 PM

Filtering the input file with certain rules
 
I have file having follwing input :
1 ABCD : M1-1-74 , A1-9 , M2-1-74 ,
2 EFGH : 4-3-2 , 2-44 , 1-44 ,
3 HIJK : 5-1-13 , 19-2-37 , 6-1-13 , 20-2-37 ,
Output file :
1 ABCD : A1-9 ,M1-1-74 , M2-1-74 ,
2 EFGH : 4-3-2 , 2-44 , 1-44 ,
3 HIJK : 5-1-13 , 6-1-13 , 20-2-37 , 19-2-37 ,

Explanation of output :
1 ABCD : A1-9 ,M1-1-74 , M2-1-74 , ----> i.e common of (M1/M2-1-74) comes together and different A1-9 comes at first.
2 EFGH : 4-3-2 , 2-44 , 1-44 , ----> i.e Common of (1/2-44) comes together and different 4-3-2 comes at first.
3 HIJK : 5-1-13 , 6-1-13 , 20-2-37 , 19-2-37 , --------> i.e Common of 5/6-1-13 comes together and 20/19-2-37 comes together.

evo2 08-05-2013 08:44 PM

Hi,

are you planning to write a program to do this manipulation? Do you have a question?

Cheers,

Evo2.

sumit.inform 08-06-2013 09:49 AM

I have made a script in expect but right now i am taking input by manipulation from Excel , I want this fully automated.

evo2 08-06-2013 07:54 PM

Hi,
Quote:

Originally Posted by sumit.inform (Post 5004051)
I have made a script in expect but right now i am taking input by manipulation from Excel , I want this fully automated.

Ok. I think the easiest approach is to save the file as a csv (or other plain text) and then process that file with a script (without using expect). The script a shell script or could use pure awk or perhaps python or perl. Which language you choose depends on which you are most comfortable with.

If you really want to go the extra mile it is possible to process excel files directly (without exporting to csv). I've used the xlrd and xlwr libraries in python to do this.

Evo2.


All times are GMT -5. The time now is 02:26 PM.