Computing pair-wise time differences in mili seconds between matching records in a data tableGet row data for...
In a topological space if there exists a loop that cannot be contracted to a point does there exist a simple loop that cannot be contracted also?
French equivalent of "Make leaps and bounds"
Look mom! I made my own (Base 10) numeral system!
Does this smartphone photo show Mars just below the Sun?
Do other countries guarantee freedoms that the United States does not have?
Using Select on Dataset with missing keys
Does this put me at risk for identity theft?
Ampacity of Conductive Tape
What does VB stand for?
How to avoid ci-driven development..?
Whats the name of this projection?
Is Odin inconsistent about the powers of Mjolnir?
Non-OR journals which regularly publish OR research
In Pokémon Go, why does one of my Pikachu have an option to evolve, but another one doesn't?
Validation and verification of mathematical models
Where to pee in London?
Is there a loss of quality when converting RGB to HEX?
In the movie Harry Potter and the Order or the Phoenix, why didn't Mr. Filch succeed to open the Room of Requirement if it's what he needed?
What does Fisher mean by this quote?
What are good ways to improve as a writer other than writing courses?
How quickly could a country build a tall concrete wall around a city?
Short story about a teenager who has his brain replaced with a microchip (Psychological Horror)
How would a family travel from Indiana to Texas in 1911?
How is the return type of a ternary operator determined?
Computing pair-wise time differences in mili seconds between matching records in a data table
Get row data for non-matching column valuesCan the string “abcedf” be matched to string “bafcde” in a single line command?Extracting all columns containing a list of termsReplacing all non-zero results with “1” to form presence/absenceCompute Mean Values associate with the same identifierusing sed in loopShell script to filter date alone from a particular column of a .csv file and save the output in another csv fileComputing pair-wise time differences between matching records in a data tableintersection beween 2 files (values in file 1 which fall in range of values in file 2)Calculate the time difference between two columns in time format hh:mm:ss
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I have a three-column table of data of the following form:
TIME MPID CPID
14:00:04.909 10048 370007
14:00:05.320 10048 370007
14:00:05.462 10048 370008
14:00:05.761 10048 370008
14:00:05.809 10048 370009
14:00:05.833 10048 370009
14:00:11.320 10048 370010
14:00:11.453 10048 370010
14:00:11.693 10048 370011
14:00:13.097 10048 370012
14:00:14.124 10048 370012
Here the TIME column consists of timestamps of the form HH:MM:SS.SSS The MPID and CPID columns are identification numbers; what they mean is not important for my question. The MPID values also don't play a role, except for the fact that they're present in the data set and need to be propagated to the output.
What I want is to identify pairs of rows which have matching CPID values and compute the difference between their corresponding times. So, for example, there are two rows (the third and the fourth) in the above example with CPID 77846. The corresponding times are 14:00:05.320 and 14:00:05.589, so I want to compute the difference:
14:00:04.909 - 14:00:05.320 = 00:00:00.589
I would also like to output this result in the following format:
MPID 10051 CPID 77846 Total time difference: 589 mili seconds
If a given CPID does not occur exactly twice in the data set then I want to ignore it.
The desired output for the given example data should look like this:
MPID 10051 CPID 77845 Total time difference: 1400 milli seconds
MPID 10051 CPID 77846 Total time difference: 1300 milli seconds
MPID 10051 CPID 77847 Total time difference: 800 milli seconds
MPID 10051 CPID 77848 Total time difference: 1800 milli seconds
MPID 10051 CPID 77849 Total time difference: 1900 milli seconds
Currently using Script:
uniq -D -f 2 "${1}" |
while read a b c && read d e f ; do
g=$(( $(date -d $d +%s) - $(date -d $a +%s) ))
printf "MPID %s CPID %s Total time difference: %02i secondsn" $b $c $g
done
Output Giving
MPID 10051 CPID 77845 Total time difference: 00 seconds
MPID 10051 CPID 77846 Total time difference: 03 seconds
MPID 10051 CPID 77847 Total time difference: 12 seconds
MPID 10051 CPID 77848 Total time difference: 15 seconds
MPID 10051 CPID 77849 Total time difference: 19 seconds
linux shell-script awk sed perl
add a comment |
I have a three-column table of data of the following form:
TIME MPID CPID
14:00:04.909 10048 370007
14:00:05.320 10048 370007
14:00:05.462 10048 370008
14:00:05.761 10048 370008
14:00:05.809 10048 370009
14:00:05.833 10048 370009
14:00:11.320 10048 370010
14:00:11.453 10048 370010
14:00:11.693 10048 370011
14:00:13.097 10048 370012
14:00:14.124 10048 370012
Here the TIME column consists of timestamps of the form HH:MM:SS.SSS The MPID and CPID columns are identification numbers; what they mean is not important for my question. The MPID values also don't play a role, except for the fact that they're present in the data set and need to be propagated to the output.
What I want is to identify pairs of rows which have matching CPID values and compute the difference between their corresponding times. So, for example, there are two rows (the third and the fourth) in the above example with CPID 77846. The corresponding times are 14:00:05.320 and 14:00:05.589, so I want to compute the difference:
14:00:04.909 - 14:00:05.320 = 00:00:00.589
I would also like to output this result in the following format:
MPID 10051 CPID 77846 Total time difference: 589 mili seconds
If a given CPID does not occur exactly twice in the data set then I want to ignore it.
The desired output for the given example data should look like this:
MPID 10051 CPID 77845 Total time difference: 1400 milli seconds
MPID 10051 CPID 77846 Total time difference: 1300 milli seconds
MPID 10051 CPID 77847 Total time difference: 800 milli seconds
MPID 10051 CPID 77848 Total time difference: 1800 milli seconds
MPID 10051 CPID 77849 Total time difference: 1900 milli seconds
Currently using Script:
uniq -D -f 2 "${1}" |
while read a b c && read d e f ; do
g=$(( $(date -d $d +%s) - $(date -d $a +%s) ))
printf "MPID %s CPID %s Total time difference: %02i secondsn" $b $c $g
done
Output Giving
MPID 10051 CPID 77845 Total time difference: 00 seconds
MPID 10051 CPID 77846 Total time difference: 03 seconds
MPID 10051 CPID 77847 Total time difference: 12 seconds
MPID 10051 CPID 77848 Total time difference: 15 seconds
MPID 10051 CPID 77849 Total time difference: 19 seconds
linux shell-script awk sed perl
add a comment |
I have a three-column table of data of the following form:
TIME MPID CPID
14:00:04.909 10048 370007
14:00:05.320 10048 370007
14:00:05.462 10048 370008
14:00:05.761 10048 370008
14:00:05.809 10048 370009
14:00:05.833 10048 370009
14:00:11.320 10048 370010
14:00:11.453 10048 370010
14:00:11.693 10048 370011
14:00:13.097 10048 370012
14:00:14.124 10048 370012
Here the TIME column consists of timestamps of the form HH:MM:SS.SSS The MPID and CPID columns are identification numbers; what they mean is not important for my question. The MPID values also don't play a role, except for the fact that they're present in the data set and need to be propagated to the output.
What I want is to identify pairs of rows which have matching CPID values and compute the difference between their corresponding times. So, for example, there are two rows (the third and the fourth) in the above example with CPID 77846. The corresponding times are 14:00:05.320 and 14:00:05.589, so I want to compute the difference:
14:00:04.909 - 14:00:05.320 = 00:00:00.589
I would also like to output this result in the following format:
MPID 10051 CPID 77846 Total time difference: 589 mili seconds
If a given CPID does not occur exactly twice in the data set then I want to ignore it.
The desired output for the given example data should look like this:
MPID 10051 CPID 77845 Total time difference: 1400 milli seconds
MPID 10051 CPID 77846 Total time difference: 1300 milli seconds
MPID 10051 CPID 77847 Total time difference: 800 milli seconds
MPID 10051 CPID 77848 Total time difference: 1800 milli seconds
MPID 10051 CPID 77849 Total time difference: 1900 milli seconds
Currently using Script:
uniq -D -f 2 "${1}" |
while read a b c && read d e f ; do
g=$(( $(date -d $d +%s) - $(date -d $a +%s) ))
printf "MPID %s CPID %s Total time difference: %02i secondsn" $b $c $g
done
Output Giving
MPID 10051 CPID 77845 Total time difference: 00 seconds
MPID 10051 CPID 77846 Total time difference: 03 seconds
MPID 10051 CPID 77847 Total time difference: 12 seconds
MPID 10051 CPID 77848 Total time difference: 15 seconds
MPID 10051 CPID 77849 Total time difference: 19 seconds
linux shell-script awk sed perl
I have a three-column table of data of the following form:
TIME MPID CPID
14:00:04.909 10048 370007
14:00:05.320 10048 370007
14:00:05.462 10048 370008
14:00:05.761 10048 370008
14:00:05.809 10048 370009
14:00:05.833 10048 370009
14:00:11.320 10048 370010
14:00:11.453 10048 370010
14:00:11.693 10048 370011
14:00:13.097 10048 370012
14:00:14.124 10048 370012
Here the TIME column consists of timestamps of the form HH:MM:SS.SSS The MPID and CPID columns are identification numbers; what they mean is not important for my question. The MPID values also don't play a role, except for the fact that they're present in the data set and need to be propagated to the output.
What I want is to identify pairs of rows which have matching CPID values and compute the difference between their corresponding times. So, for example, there are two rows (the third and the fourth) in the above example with CPID 77846. The corresponding times are 14:00:05.320 and 14:00:05.589, so I want to compute the difference:
14:00:04.909 - 14:00:05.320 = 00:00:00.589
I would also like to output this result in the following format:
MPID 10051 CPID 77846 Total time difference: 589 mili seconds
If a given CPID does not occur exactly twice in the data set then I want to ignore it.
The desired output for the given example data should look like this:
MPID 10051 CPID 77845 Total time difference: 1400 milli seconds
MPID 10051 CPID 77846 Total time difference: 1300 milli seconds
MPID 10051 CPID 77847 Total time difference: 800 milli seconds
MPID 10051 CPID 77848 Total time difference: 1800 milli seconds
MPID 10051 CPID 77849 Total time difference: 1900 milli seconds
Currently using Script:
uniq -D -f 2 "${1}" |
while read a b c && read d e f ; do
g=$(( $(date -d $d +%s) - $(date -d $a +%s) ))
printf "MPID %s CPID %s Total time difference: %02i secondsn" $b $c $g
done
Output Giving
MPID 10051 CPID 77845 Total time difference: 00 seconds
MPID 10051 CPID 77846 Total time difference: 03 seconds
MPID 10051 CPID 77847 Total time difference: 12 seconds
MPID 10051 CPID 77848 Total time difference: 15 seconds
MPID 10051 CPID 77849 Total time difference: 19 seconds
linux shell-script awk sed perl
linux shell-script awk sed perl
asked 43 mins ago
Vivek NigamVivek Nigam
482 silver badges9 bronze badges
482 silver badges9 bronze badges
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f534658%2fcomputing-pair-wise-time-differences-in-mili-seconds-between-matching-records-in%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f534658%2fcomputing-pair-wise-time-differences-in-mili-seconds-between-matching-records-in%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown