Spotfire 11.3: Compare column value to previous row - spotfire

I have a table of data in Spotfire, and I'm trying to create a calculated column that compares the Top Depth in a row to the Top Depth in the previous row (rounded to the second decimal). I've searched around Google and came up with the following code:
CASE
WHEN
First([TOP DEPTH]) OVER (Intersect([UWI],[FORMATION],[SOURCE]))=First([TOP DEPTH]) OVER ([UWI],[FORMATION],[SOURCE]) THEN
"Same"
Else "Different"
END
Here is the result:
UWI
FORMATION
SOURCE
TOP DEPTH
ROW_CHANGED_DATE
Origin of data
Top in Both DBs
Different Top MD
SWD 5B1-36-722
BIRDS_NEST
KPB
3726.18
9/27/2022 8:39 AM
GGX
Yes
Same
SWD 5B1-36-722
BIRDS_NEST
KPB
3726.17799495722
2/28/2022 11:43 AM
KGDM
Yes
Same
SWD 5B1-36-722
MAHOGANY
KPB
4298.83
9/27/2022 8:39 AM
GGX
Yes
Same
SWD 5B1-36-722
MAHOGANY
KPB
4298.83061688323
2/28/2022 11:43 AM
KGDM
Yes
Same
SWD 5B1-36-722
UT_GREEN_RIVER
KPB
3338.89
11/2/2022 6:41 AM
GGX
Yes
Same
SWD 5B1-36-722
UT_GREEN_RIVER
KPB
3338.89269012779
2/28/2022 11:43 AM
KGDM
Yes
Same
SWD 7A1-35-722
BIRDS_NEST
KPB
3851.15
11/16/2022 12:46 PM
GGX
Yes
Same
SWD 7A1-35-722
BIRDS_NEST
KPB
3751.14809387324
2/28/2022 11:38 AM
KGDM
Yes
Same
SWD 7A1-35-722
MAHOGANY
KPB
4323.8
11/16/2022 12:40 PM
GGX
Yes
Same
SWD 7A1-35-722
MAHOGANY
KPB
4323.80061282113
2/28/2022 11:38 AM
KGDM
Yes
Same
SWD 7A1-35-722
UT_GREEN_RIVER
KPB
3363.86
11/16/2022 12:40 PM
GGX
Yes
Same
SWD 7A1-35-722
UT_GREEN_RIVER
KPB
3363.86278904381
2/28/2022 11:34 AM
KGDM
Yes
Same
If you look at rows 7 and 8, they are being marked as having the same Top MD (or Depth), but they should be marked as different.
I cannot seem to find a decent location to site to get additional information on how to use the different expressions and functions. If someone could help me out on what should be an easy question, I would really appreciate it.
Also, if anyone has any suggestions on where to go to get more information on how to use the Spotfire expressions, I would appreciate it.
Thanks!

I can do it via an intermediate column, but according to your stated requirements, I would say the first value
in each group should be fixed (you decide either empty, or False, or True) because there is no previous row in that group to compare to.
Intermediate column: the row id
[id] calculated as
rowId()
Final column: if you want the first value to be empty
Round([TOP DEPTH],2)=Round(Last([TOP DEPTH]) over (Intersect(Previous([id]),[UWI],[FORMATION],[SOURCE])),2)
if you want the first value to be True:
SN(Round([TOP DEPTH],2)=Round(Last([TOP DEPTH]) over (Intersect(Previous([id]),[UWI],[FORMATION],[SOURCE])),2),True)
or False:
SN(Round([TOP DEPTH],2)=Round(Last([TOP DEPTH]) over (Intersect(Previous([id]),[UWI],[FORMATION],[SOURCE])),2),False)
On YouTube there is the Dr Spotfire series of videos, you should be able to find more information there.

Related

Changing the change timestamp on a file Linux

So I am trying to alter the change timestamp on a file using a script I got from here: Setting/changing the ctime or "Change time" attribute on a file
#!/bin/sh
now=$(date)
echo $now
sudo date --set="qui nov 7 21:05:56 WET 2018"
chmod 777 $1
sudo date --set="$now"
This is the output:
qui nov 8 18:19:39 WET 2018
date: invalid date ‘qui nov 7 21:05:56 WET 2018’
date: invalid date ‘qui nov 8 18:19:39 WET 2018’
What is the matter? The output from date is not a valid date? I tried the fix suggested in the comment to the answer I linked, but it also doesn't work.
AFAIK The reason why the arguments are different:
$ info date
Invoking 'date' with no FORMAT argument is equivalent to invoking it
with a default format that depends on the 'LC_TIME' locale category.
While under Setting the time:
If given an argument that does not start with '+', 'date' sets the
system clock to the date and time specified by that argument (as
described below). You must have appropriate privileges to set the
system clock. Note for changes to persist across a reboot, the hardware
clock may need to be updated from the system clock, which might not
happen automatically on your system.
The argument must consist entirely of digits, which have the
following meaning:
'MM'
month
'DD'
day within month
'hh'
hour
'mm'
minute
'CC'
first two digits of year (optional)
'YY'
last two digits of year (optional)
'ss'
second (optional)
Note, the '--date' and '--set' options may not be used with an
argument in the above format. The '--universal' option may be used with
such an argument to indicate that the specified date and time are
relative to Coordinated Universal Time rather than to the local time
zone.

Tail command to display matched pattern

I have a log file which logs network activities. I want to view the log file, but I want to see matched pattern. I mean I want to see the content of my choice. The log file is in this format: Nov 7 12:00:00 ......... How can I view content of a specific date or specific time. I mean if I want to see only 3:00 to 5:00 on Nov 7 how can I use the tail command to do that?
There are multiple ways to do what you want. One of them using grep is
grep '^Nov 7 0[3-5]:' network.log | less

Cronjob is triggered automatically

I have created a cron job, which needs to be triggered at 00:01 on the daily basis. Below are the details:
Cronjob configuration:
01 00 * * * root /usr/bin/python /opt/scripts/tune.py -t & >/dev/null &
Permissions and location of file:
root#localhost:/etc/cron.d# ll /etc/cron.d/database_tuning
-rw-r--r-- 1 root root 80 Oct 12 01:04 /etc/cron.d/database_tuning
However, this cronjob is not triggered automatically at the specified interval. Now, once I edit this file, and change time to 01:12 AM like (12 01 * * *). then it is triggered automatically successfully. So I confirmed that there is no problem with the script/environment, but I am not able to understand that why cronjob is not triggered at 00:01 AM. What is the best possible to debug this ?
As Ali also stated, the hour field must be a value between 0-23, so it won't work if you write 00.
The time and date fields are:
field allowed values
----- --------------
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sunday, or use names)
A field may contain an asterisk (*), which always stands for
"first-last".
Take a look at crontab manual page.

How can I save records in psql during iteration in a file

I have a file that contains just id. the id matches one of the columns in table. I want to extract records in that column and get the result in csv file. I don't want to create another table.
I have docid.txt file with the following data:
12000072
112073
11279
1182
11188
11182094
82099
11102
Each of these correspond to a nameid column in student table. student table has:
name nameid dob performance
-------------------------------------------
andre 12000072 12/4/1990 Excellent
Scott 112073 12/5/1999 Good
Reagan 2692882 15/7/2003 fair
Aldo 1402508 4/7/1998 Poor
Mary 2266257 5/11/1995 Very good
Walt 11182094 3/12/2000 Good
Tessy 82099 8/12/1999 Very good
Skinn 11102 7/2/2002 Excellent
Smart 678016 12/4/1990 fair
John 475689 12/5/1999 Poor
Rita 2796799 12/4/1990 Very good
Rachael 11188 12/5/1999 Poor
Gomez 3075168 3/12/2000 Very good
Becham 3075168 4/7/1998 Good
Walker 1050879 5/11/1995 Very good
Tommy 2017451 3/12/2000 Excellent
Trevor 11279 7/2/2002 Good
Litin 1182 12/5/1999 fair
Martha 883368 15/7/2003 fair
Rafael 3070833 4/7/1998 Poor
Kim 3070833 5/11/1995 Very good
Clichy 255918 12/4/1990 Good
Mario 2706915 12/5/1999 Excellent
I want to remove students with docid from student table. I tried the following:
for i in `cat docid.txt;` do
`psql -A -t $dbname $username << EOF`
`select * from student where nameid = $i;`
`EOF`
`done >>docid.csv`
Thank you
Assuming you're using PostgreSQL, I suggest copying them into a temp table, then joining on it.
e.g.
$ psql <<'__END__'
BEGIN;
CREATE TEMPORARY TABLE docids (docid integer) ON COMMIT DROP;
\copy docids from 'docids.txt'
DELETE FROM student USING docids WHERE nameid = docid;
COMMIT;
__END__
In addition to being cleaner and simpler than a loop, it's going to be way faster, and it'll either succeed or fail as a unit without leaving half-completed work on an error.
If you want to output the deleted rows, append RETURNING * to the DELETE statement, and run with psql -q to suppress other output.

Timezone in date?

From where does the date command in Linux get the timezone information?
I cannot see /etc/localtime file and /usr/share/zoneinfo directory in my system. Still when i execute the date command i get the following output
Thu Dec 9 16:28:18 UTC 2010
Kindly tell me from where does the command get the timezone information?
Thanks,
LinuxPenseur
Don't forget that UTC is how standard Unix systems store the date/time in the real time clock. You have to jump through hoops using funny programs (see the hwclock(8) manpage) if you dual-boot to Windows, which prefers the local time to be stored in the CMOS real time clock.
So the date(1) program is simply showing you the results of "I have no configured time zone":
# date -u
Thu Dec 9 10:40:54 UTC 2010
# TZ=UTC date
Thu Dec 9 10:40:57 UTC 2010
# TZ=PST8PDT date
Thu Dec 9 02:41:02 PST 2010
#
From http://www.wikihow.com/Change-the-Timezone-in-Linux
On mobile phones and other small devices that run Linux, the time zone
is stored differently. It is written in /etc/TZ, in the format that is
described, for instance, in [4] . Edit this file manually or use
echo (for instance, echo GMT0BST > /etc/TZ to set the the timezone of
the United Kingdom).
From http://www.radisys.com/files/support_downloads/03245-02_MPCMM0001_MPCMM0002_CMM_Software_TPS.pdf
The CMM determines the offset to local timezone maintained in file
/etc/cmm/TZ and automatically updates the time.
This should help :
http://www.hypexr.org/linux_date_time_help.php

Resources