10-16-2013
Search for string in a file then compare it with excel files entry
All,
i have a file text.log:
cover6
cover3
cover2
cover4
other file is abc.log as :
0
0
1
0
Then I have a excel file result.xls that contains:
Name Path Pass
cover2
cover3
cover6
cover4
Now I want to write a perl script that will check if 1st column and 2nd row of results.xls is equal to first string of text.log then, write 1st string of abc.log in 3rd column 1st row of result.xls i.e under Pass field.
example : Row 2 of result.xls contain cover2 but in text.log cover2 is in 3rd line. So, row2 3rd column of result.xls will contain string in 3rd line of abc.log i.e 1.
Similarly for all rows.
Regards,
Anamika
---------- Post updated at 04:53 AM ---------- Previous update was at 04:28 AM ----------
Quote:
Originally Posted by
Anamika08
All,
i have a file text.log:
cover6
cover3
cover2
cover4
other file is abc.log as :
0
0
1
0
Then I have a excel file result.xls that contains:
Name Path Pass
cover2
cover3
cover6
cover4
Now I want to write a perl script that will check if 1st column and 2nd row of results.xls is equal to first string of text.log then, write 1st string of abc.log in 3rd column 1st row of result.xls i.e under Pass field.
example : Row 2 of result.xls contain cover2 but in text.log cover2 is in 3rd line. So, row2 3rd column of result.xls will contain string in 3rd line of abc.log i.e 1.
Similarly for all rows.
Regards,
Anamika
Last edited by Anamika08; 10-16-2013 at 06:53 AM..
Reason: modified details
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I need to count the number of files which have a search string, but counting the file only once
if search string is found.
eg: File1: Please note that there are 2 occurances of "aaa"
aaa
bbb
ccc
aaa
File2: Please note that there are 3 occurances of "aaa"
aaa
bbb
ccc... (1 Reply)
Discussion started by: sudheshnaiyer
1 Replies
2. Shell Programming and Scripting
Hi All,
I have a file that I need to be able to find a pattern match on a line, take the number on that line check if its >0.9 or <0.1 and if this is true write the line to output.out file.
An example of 4 lines in my file is:
1. driver.I177.I11.net010 1.48622200477273e-05
2.... (2 Replies)
Discussion started by: Crypto
2 Replies
3. UNIX for Dummies Questions & Answers
I have a couple of things I got stuck on
1)
I have a text file containing 25k search string that I need to search against compressed file. I have used this command but somehow it doesn't seems to use all the search terms.
I have put one search string per line in the txt file (I clean up... (2 Replies)
Discussion started by: m00
2 Replies
4. UNIX for Dummies Questions & Answers
Hi All,
i have a excel sheet with two columns as below.
column1 column2
100 100
200 300
300 400
400 400
500 600
i need to compare the values these two columns and the output should be printed in the third column...if these values are equal the output should be green and if these... (2 Replies)
Discussion started by: arunmanas
2 Replies
5. UNIX for Dummies Questions & Answers
Hello I am a new unix user, and I have a work related task to compare 2 files and print all of the lines in file 2 that contain a string from file 1 Note: the fields are in different columns in the files. I suspect the is a good use for awk? Thanks for your time & help
File 1
123 232 W343... (6 Replies)
Discussion started by: KevinRidley
6 Replies
6. Shell Programming and Scripting
Hi,
I have multiple files that each contain one column of strings:
File1:
123abc
456def
789ghi
File2:
123abc
456def
891jkl
File3:
234mno
123abc
456def
In total I have 25 of these type of file. (5 Replies)
Discussion started by: owwow14
5 Replies
7. Shell Programming and Scripting
All,
I have an excel sheet Excel1.xls that has some entries.
I have one more excel sheet Excel2.xls that has entries only in those cells which are blank in Excel1.xls
These may be in different workbooks. They are totally independent made by 2 different users.
I have placed them in a... (1 Reply)
Discussion started by: Anamika08
1 Replies
8. Shell Programming and Scripting
Hi,
Need your help for this scripting issue I have. I am not really good at this, so seeking your help.
I have a file looking similar to this:
Hello, i am human and name=ABCD.
How are you?
Hello, i am human and name=PQRS.
I am good.
Hello, i am human and name=ABCD.
Good bye.
Hello, i... (12 Replies)
Discussion started by: royzlife
12 Replies
9. Shell Programming and Scripting
Hello All
I have a pattern.txt file in source directory ((/project/source/) in linux server and data looks like:
123abc17
234cdf19
235ifg20
I have multiple log files in log directory (/project/log/) in linux server and data for one log file looks like:
<?xml version="1.0" processid... (11 Replies)
Discussion started by: pred55
11 Replies
10. UNIX for Beginners Questions & Answers
Hi All,
I hope somebody would be able to help me.
I would need to search a string coming from a file, example file.txt:
dog
cat
goat
horse
fish
For every string, I would need to know if there are any files inside a directory(recursively) that contains the string regardless of case.... (9 Replies)
Discussion started by: kokoro
9 Replies
LEARN ABOUT DEBIAN
algorithm::munkres
Algorithm::Munkres(3pm) User Contributed Perl Documentation Algorithm::Munkres(3pm)
NAME
Algorithm::Munkres - Perl extension for Munkres' solution to
classical Assignment problem for square and rectangular matrices
This module extends the solution of Assignment problem for square
matrices to rectangular matrices by padding zeros. Thus a rectangular
matrix is converted to square matrix by padding necessary zeros.
SYNOPSIS
use Algorithm::Munkres;
@mat = (
[2, 4, 7, 9],
[3, 9, 5, 1],
[8, 2, 9, 7],
);
assign(@mat,@out_mat);
Then the @out_mat array will have the output as: (0,3,1,2),
where
0th element indicates that 0th row is assigned 0th column i.e value=2
1st element indicates that 1st row is assigned 3rd column i.e.value=1
2nd element indicates that 2nd row is assigned 1st column.i.e.value=2
3rd element indicates that 3rd row is assigned 2nd column.i.e.value=0
DESCRIPTION
Assignment Problem: Given N jobs, N workers and the time taken by
each worker to complete a job then how should the assignment of a
Worker to a Job be done, so as to minimize the time taken.
Thus if we have 3 jobs p,q,r and 3 workers x,y,z such that:
x y z
p 2 4 7
q 3 9 5
r 8 2 9
where the cell values of the above matrix give the time required
for the worker(given by column name) to complete the job(given by
the row name)
then possible solutions are:
Total
1. 2, 9, 9 20
2. 2, 2, 5 9
3. 3, 4, 9 16
4. 3, 2, 7 12
5. 8, 9, 7 24
6. 8, 4, 5 17
Thus(2) is the optimal solution for the above problem.
This kind of brute-force approach of solving Assignment problem
quickly becomes slow and bulky as N grows, because the number of
possible solution are N! and thus the task is to evaluate each
and then find the optimal solution.(If N=10, number of possible
solutions: 3628800 !)
Munkres' gives us a solution to this problem, which is implemented
in this module.
This module also solves Assignment problem for rectangular matrices
(M x N) by converting them to square matrices by padding zeros. ex:
If input matrix is:
[2, 4, 7, 9],
[3, 9, 5, 1],
[8, 2, 9, 7]
i.e 3 x 4 then we will convert it to 4 x 4 and the modified input
matrix will be:
[2, 4, 7, 9],
[3, 9, 5, 1],
[8, 2, 9, 7],
[0, 0, 0, 0]
EXPORT
"assign" function by default.
INPUT
The input matrix should be in a two dimensional array(array of
array) and the 'assign' subroutine expects a reference to this
array and not the complete array.
eg:assign(@inp_mat, @out_mat);
The second argument to the assign subroutine is the reference
to the output array.
OUTPUT
The assign subroutine expects references to two arrays as its
input paramenters. The second parameter is the reference to the
output array. This array is populated by assign subroutine. This
array is single dimensional Nx1 matrix.
For above example the output array returned will be:
(0,
2,
1)
where
0th element indicates that 0th row is assigned 0th column i.e value=2
1st element indicates that 1st row is assigned 2nd column i.e.value=5
2nd element indicates that 2nd row is assigned 1st column.i.e.value=2
SEE ALSO
1. http://216.249.163.93/bob.pilgrim/445/munkres.html
2. Munkres, J. Algorithms for the assignment and transportation
Problems. J. Siam 5 (Mar. 1957), 32-38
3. FranA~Xois Bourgeois and Jean-Claude Lassalle. 1971.
An extension of the Munkres algorithm for the assignment
problem to rectangular matrices.
Communication ACM, 14(12):802-804
AUTHOR
Anagha Kulkarni, University of Minnesota Duluth
kulka020 <at> d.umn.edu
Ted Pedersen, University of Minnesota Duluth
tpederse <at> d.umn.edu
COPYRIGHT AND LICENSE
Copyright (C) 2007-2008, Ted Pedersen and Anagha Kulkarni
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the
hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
perl v5.10.0 2008-10-22 Algorithm::Munkres(3pm)