1분 해상도("Timestamp-1min")의 2021년 타임스탬프가 있는 기본 테이블이 있습니다. 1년의 각 날짜(일출, 일몰: 황혼의 시작 및 끝)에 대한 쌍의 조건에 따라 하루 분해능("Start-End-TS1")으로 두 번째 테이블의 데이터로 기본 테이블을 채워야 합니다. 일, 월 및 [조건의 시간(시:분)].
나는 "Timestamp-1min-Result" 테이블에 있는 2021년 6월 14일에 그것을 했습니다.
Sunrise-Start, Sunrise-End 및 Twilight(Start and End)에 대한 또 다른 열인 "S Start-S End" 열을 추가했습니다. 또한 Day Length, Mid T, Twilight 시간 및 코드를 채우고 싶습니다. 열(DT/TT) - 나중에 조인할 다른 테이블과 통계를 수행하는 데 도움이 되는 주간/황혼 시간입니다. 두 번째 테이블에서 값을 가져오는 대신 수식을 사용하여 총 요일 시간과 황혼 시간(결과 테이블에서)을 채우려면 어떻게 해야 합니까? 주간(DT) 및 황혼 시간(TT)에 대한 코드를 어떻게 생성합니까?
대화식으로 수행하는 방법은 무엇입니까? 또는 JSL이 유일한 방법입니까?
원하는 작업을 수행하는 유일한 효율적인 방법은 JSL을 사용하는 것입니다.여러 수식 열을 사용하여 수행하면 50만 개의 레코드를 여러 번 읽어야 합니다.아래 JSL은 기본 테이블을 한 번만 읽습니다.
또한 하나의 테이블에서 이 모든 작업을 수행할 수 있지만 Excel을 사용하는 척하고 조회 데이터 테이블의 모든 데이터를 기본 테이블로 이동한 다음 열을 숨겨야 합니다.그것은 아름답지 않을 것입니다.다음은 문제를 해결하는 데 많은 도움이 될 것으로 생각되는 스크립트입니다.50만 개의 레코드가 있는 경우 필요한 모든 비교를 수행하는 데 몇 분이 걸립니다.스크립트는 특정 이름을 가진 2개의 데이터 테이블을 찾고 있습니다.
Names Default To Here( 1 );
dtMain = Data Table( "Timestamp-1min" );
dtLookUP = Data Table( "Start-End-TS1" );
// Add the required new colummns
dtMain << New Column( "S Start-S End", format("h:m:s"));
dtMain << New Column( "T Start-T End", format("h:m:s"));
dtMain << New Column( "Day Length", format("h:m:s"));
dtMain << New Column( "Mid T", format("h:m:s"));
dtMain << New Column( "Twilight time", format("h:m:s"));
dtMain << New Column( "DT/TT", character);
// Loop through Main table and set values
DT = "";
dl = twTime = .;
For( i = 1, i <= N Rows( dtMain ), i++,
If( i == 1 | Day( dtMain:Timestamp[i] ) != Day( dtMain:Timestamp[i - 1] ),
theRow = Try(
(dtLookUp << get rows where(
dtLookUp:Month 2 == Month( dtMain:Timestamp[i] ) & dtLookUp:Date == Day( dtMain:Timestamp[i] )
))[1],
.
)
);
// Get the time for the current row
theTime = Date MDY( 12, 31, 1899 ) + 3600 * Hour( dtMain:Timestamp[i] ) + 60 * Minute( dtMain:Timestamp[i] )
+Second( dtMain:Timestamp[i] );
theNextTime = Date MDY( 12, 31, 1899 ) + 3600 * Hour( dtMain:Timestamp[i + 1] ) + 60 *
Minute( dtMain:Timestamp[i + 1] ) + Second( dtMain:Timestamp[i + 1] );
// If this is a Twilight Start, record the time, and set the value for Twilight time
If( dtLookUp:Twilight start[theRow] >= theTime & dtLookUp:TwilightStart[theRow] <= theNextTime,
dtMain:"T Start-T End"n[i] = dtLookUp:Twilight start[theRow];
DT = "TT";
twTime = dtLookUp:Twilight Length[theRow];
);
// If this is Sunrise, recorde the time and set the value for Day Length
If( dtLookUp:Sunrise[theRow] >= theTime & dtLookUp:Sunrise[theRow] <= theNextTime,
dtMain:"S Start-S End"n[i] = dtLookUp:Sunrise[theRow];
DT = "DT";
dl = dtLookUp:Day Length[theRow];
);
// If sunset has ended record the value and blank out the day length time
If( dtLookUp:Sunset[theRow] >= theTime & dtLookUp:Sunset[theRow] <= theNextTime,
dtMain:"S Start-S End"n[i] = dtLookUp:Sunset[theRow];
DT = "TT";
dl = .;
);
// If twighlight has ended record the value and blank out the Twilight time
If( dtLookUp:Twilight End[theRow] >= theTime & dtLookUp:Twilight End[theRow] <= theNextTime,
dtMain:"T Start-T End"n[i] = dtLookUp:Twilight End[theRow];
DT = "";
twTime = .;
);
// If this is the Mid T time, record the value
If( dtLookUp:Mid T[theRow] >= theTime & dtLookUp:Mid T[theRow] <= theNextTime,
dtMain:Mid T[i] = dtLookUp:Mid T[theRow]
);
// Write the repeating values
dtMain:"DT/TT"n[i] = DT;
dtMain:Twilight time[i] = twTime;
dtMain:Day Length[i] = dl;
// Do some cleanup on ending records
If( Is Missing( dtMain:"S Start-S End"n[i] ) == 0 & Is Missing( dtMain:Day Length[i - 1] ) == 0,
dtMain:Day Length[i] = dtMain:Day Length[i - 1]
);
If( Is Missing( dtMain:"T Start-T End"n[i] ) == 0 & Is Missing( dtMain:Twilight time[i - 1] ) == 0,
dtMain:Twilight time[i] = dtMain:Twilight time[i - 1]
);
If( Is Missing( dtMain:Twilight time[i] ) == 0 & dtMain:"DT/TT"n[i] == "",
dtMain:"DT/TT"n[i] = dtMain:"DT/TT"n[i - 1]
);
);
넬슨,
놀라운! 정말 감사합니다!!!
스크립팅 연습을 어디서부터 시작해야 하는지 알아야 합니다. 따라하고 DIY할 수 있는 기본 스크립팅 예제가 있습니까?