Perform Operations on One File Conditional on Data in Another File


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perform Operations on One File Conditional on Data in Another File
Prev   Next
# 1  
Old 09-19-2011
Perform Operations on One File Conditional on Data in Another File

Hello all,

I am looking for a solution to the following problem. Perl or python solutions also welcome.

Given this input:

Quote:
0.788 0.901 0.500
0.675 0.812 1
And this input:

Quote:
A A A B B B
B B B A A A
I want to get this output.

Quote:
0 0 A B 0 0
0 0 0 0 A A
The rule being that if the number in the first file is < 0.9, then the corresponding two columns on the same line in the other file are set to 0.

Thanks in advance.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk script to find data in three file and perform replace operation

Have three files. Any other approach with regards to file concatenation or splitting, etc is appreciated If column55(billngtype) of file1 contains YMNC or YPBC then pick the value of column13(documentnumber). Now find this documentnumber in column1(Billdoc) of file2 and grep the corresponding... (4 Replies)
Discussion started by: as7951
4 Replies

2. Shell Programming and Scripting

How to perform multiple operations on a number before storing to a variable?

(I am using bash) I have a command that will find the line number in a file by searching for a string where it exists. linenumber=$(grep -n "string" $FILENAME | cut -d : -fi) This returns the line number and removes the string. Now that I have the line number I want to subtract 4 from it and... (5 Replies)
Discussion started by: prodigious8
5 Replies

3. Shell Programming and Scripting

Filter on one column and then perform conditional calculations on another column with a Linux script

Hi, I have a file (stats.txt) with columns like in the example below. Destination IP address, timestamp, TCP packet sequence number and packet length. destIP time seqNo packetLength 1.2.3.4 0.01 123 500 1.2.3.5 0.03 44 1500 1.3.2.5 0.08 44 1500 1.2.3.4 0.44... (12 Replies)
Discussion started by: Zooma
12 Replies

4. Shell Programming and Scripting

Getting lines between patterns and perform operations

Hi, I'm currently dev'ing using awk and I'm currently stuck. Here's the file, with comments on "<--- ": Record <--- First Pattern Amount 1 <--- Amount on first transaction TotalSales 0 <--- Total Sales Prior from previous transactions Time 1:00:00 <--- Time... (9 Replies)
Discussion started by: Jin_
9 Replies

5. Shell Programming and Scripting

awk - sed / reading from a data file and doing algebraic operations

Hi everyone, I am trying to write a bash script which reads a data file and does some algebraic operations. here is the structure of data.xml file that I have; 1 <data> 2 . 3 . 4 . 5 </data> 6 <data> 7 . 8 . 9 . 10</data> etc. Each data block contains same number of lines (say... (4 Replies)
Discussion started by: hayreter
4 Replies

6. Shell Programming and Scripting

Perform operations as a non root user

Hi All, I need a help in the below scenario. I want to perform few operations as a non root user but those operations can be performed only by the root user. For example I need to modify /etc/hosts file as a non root user. This is just one scenario. Could you please provide... (3 Replies)
Discussion started by: kalpeer
3 Replies

7. Shell Programming and Scripting

How to search and append words in the same file using unix scripting file operations

Hi , I have a file myhost.txt which contains below, 127.0.0.1 localhost 1.17.1.5 atrpx958 11.17.10.11 atrpx958zone nsybhost I need to append words only after "atrpx958" like 'myhost' and 'libhost' and not after atrpx958zone. How to search the word atrpx958(which is hostname) only,... (5 Replies)
Discussion started by: gsreeni
5 Replies

8. Shell Programming and Scripting

Perform Lookup File In Perl From One input File

Hi Perl Guru, I'm new to Perl Programming & need some help. I need to have some kind of similar code template so I can start to work on it. I'm been reading some forums and did not find anything that are similar so I start to work on it. I've been struggling on how to start it. Any... (1 Reply)
Discussion started by: devvvt168
1 Replies

9. Shell Programming and Scripting

Can sed perform editing operations ONLY in the matched region?

Hi: Let's suppose I want to replace all the | by > ONLY when | is between . Usually (and it works) I would do something like sed -e 's/\(\*\)|\(*\]\)/\1>\2/g' where I have to "save" some portions of the matched region and use them with the \n metacharacter. I was wondering if I could... (2 Replies)
Discussion started by: islegmar
2 Replies

10. UNIX for Dummies Questions & Answers

File operations

Hi I have a tab delimited file with 3 fields. I need to sort this file on the first field and remove all the records where the first field has dulplicates. For eg my file is 133|arrfdfdg|sdfdsg 234|asfsdgfs|aasdfs 133|affbfsde|dgfg When this file gets sorted I need the result to be ... (2 Replies)
Discussion started by: monks
2 Replies
Login or Register to Ask a Question
File::HomeDir::Windows(3pm)				User Contributed Perl Documentation			       File::HomeDir::Windows(3pm)

NAME
File::HomeDir::Windows - Find your home and other directories on Windows SYNOPSIS
use File::HomeDir; # Find directories for the current user (eg. using Windows XP Professional) $home = File::HomeDir->my_home; # C:Documents and Settingsmylogin $desktop = File::HomeDir->my_desktop; # C:Documents and SettingsmyloginDesktop $docs = File::HomeDir->my_documents; # C:Documents and SettingsmyloginMy Documents $music = File::HomeDir->my_music; # C:Documents and SettingsmyloginMy DocumentsMy Music $pics = File::HomeDir->my_pictures; # C:Documents and SettingsmyloginMy DocumentsMy Pictures $videos = File::HomeDir->my_videos; # C:Documents and SettingsmyloginMy DocumentsMy Video $data = File::HomeDir->my_data; # C:Documents and SettingsmyloginLocal SettingsApplication Data DESCRIPTION
This module provides Windows-specific implementations for determining common user directories. In normal usage this module will always be used via File::HomeDir. Internally this module will use Win32::GetFolderPath to fetch the location of your directories. As a result of this, in certain unusual situations (usually found inside large organisations) the methods may return UNC paths such as "\cifs.localhome$". If your application runs on Windows and you want to have it work comprehensively everywhere, you may need to implement your own handling for these paths as they can cause strange behaviour. For example, stat calls to UNC paths may work but block for several seconds, but opendir() may not be able to read any files (creating the appearance of an existing but empty directory). To avoid complicating the problem any further, in the rare situation that a UNC path is returned by "GetFolderPath" the usual -d validation checks will not be done. SUPPORT
See the support section the main File::HomeDir module. AUTHORS
Adam Kennedy <adamk@cpan.org> Sean M. Burke <sburke@cpan.org> SEE ALSO
File::HomeDir, File::HomeDir::Win32 (legacy) COPYRIGHT
Copyright 2005 - 2011 Adam Kennedy. Some parts copyright 2000 Sean M. Burke. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.14.2 2012-01-25 File::HomeDir::Windows(3pm)