-
Notifications
You must be signed in to change notification settings - Fork 0
/
comp_test.cmd
51 lines (46 loc) · 1.74 KB
/
comp_test.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
@echo off
Setlocal EnableDelayedExpansion
set "new_doc=new"
set "comp_doc=complete"
set "list1=test_list1"
set "list2=test_list2"
if exist %new_doc%.csv (
type nul > test_new.csv && attrib +h test_new.csv
type nul > test_comp.csv && attrib +h test_comp.csv
call :reformat %new_doc%.csv , test_new.csv
call :reformat %comp_doc%.csv , test_comp.csv
) else (( echo File Error: %new_doc%.csv not found. ) && pause &exit /b 1 )
if exist test_comp.csv ( if exist test_new.csv (
type nul > %list1%.csv && attrib +h %list1%.csv
type nul > %list2%.csv && attrib +h %list2%.csv
call :extract test_new.csv , %list1%.csv , "tokens=1 delims=,"
call :extract test_comp.csv , %list2%.csv , "tokens=1 delims=,"
sort /uniq %list1%.csv /o test_list11.csv && attrib +h test_list11.csv
sort /uniq %list2%.csv /o test_list22.csv && attrib +h test_list22.csv
)) else (( echo File Error: %comp_doc%.csv not found. ) && del /A:H test_new.csv && pause &exit /b 1 )
echo Missing codes found: > test_error.csv
for /f %%a in ('fc test_list11.csv test_list22.csv ^| find /i "cod"') do ( echo %%a >> test_error.csv )
del /A:H %list1%.csv %list2%.csv test_list11.csv test_list22.csv test_new.csv test_comp.csv
pause
exit
:reformat
for /f "skip=1 delims=" %%# in (%1) do (
REM error handle - for comma delimiter sequences
REM and empty values in tuple - with replacement
set tpl=%%#
set tpl=!tpl:,,=, ,!
set tpl=!tpl:,,=, ,!
for /f "tokens=2-7 delims=," %%b in (^"!tpl!^") do (
REM exhibit parsed token selectivity
echo %%b,%%d,%%e,%%f,%%g >> %2
)
)
exit /b
:extract
for /f %3 %%a in (%1) do (
REM token selectivity for unique id column
REM at position 1 - after reformat subroutine
echo %%a >> %2
)
exit /b
goto :eof