Nice challenge. Here is a pure batch solution:
@echo off
setlocal enabledelayedexpansion
REM following code to produce some data for testing:
(
echo date,hour,temp
echo 20181231,24,99
for /l %%a in (1,1,9) do @for /l %%b in (1,1,24) do @echo 2019010%%a,%%b,!random:~-2!
for /l %%a in (1,1,9) do @for /l %%b in (1,1,24) do @echo 2019011%%a,%%b,!random:~-2!
for /l %%a in (1,1,9) do @for /l %%b in (1,1,24) do @echo 2019012%%a,%%b,!random:~-2!
)>hourdata-test.csv
REM code to extract desired values
REM expected hour-pairs: 1,2 - 10,11 - 19,20 - 4,5 - 13,14 - 22,23 - 7,8 - 16,17 : repeat
(for /f "tokens=1,* delims=:" %%a in ('findstr /n "^" hourdata-test.csv') do (
set /a "x=%%a %% 9"
if !x! == 3 echo %%b
if !x! == 4 echo %%b
))>ninerdata.csv
The trick is to use the line numbers, calculate Modulo 9
and then simply compare the resulting value. Skipping the first two lines is achieved by printing the modulo numbers 3 and 4.
A full year of data should take less than 2 seconds.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…