Я сделал этот скрипт ниже:
@echo off
setlocal enabledelayedexpansion
(for /f "skip=2 tokens=2,3,7 delims=;" %%a in (1.csv) do (
set "a=%%a "
set "b=%%b "
for /f "tokens=1,*" %%m in ("%%c") do (set "c= %%m" & set "d= %%n")
echo !a:~0,22!!b:~0,17!!c!!d:~-10!
))>2.csv
<2.csv set /p header=
(echo %header%
more +1 2.csv |sort /+22) >3.csv
set "NewFile=4.csv"
set "TotalElo=0"
set "TotalMastercard=0"
set "TotalAmericanExpress=0"
set "TotalVisa=0"
set "TotalOther1=0"
set "TotalOther2=0"
set "TotalOther3=0"
for %%I in (3.csv) do (
for /F "skip=1 tokens=3 delims=" %%A in ("%%I") do (
set /A TotalElo+=%%A
set /A TotalMastercard+=%%B
set /A TotalAmericanExpress+=%%C
set /A TotalVisa+=%%D
set /A TotalOther1+=%%E
set /A TotalOther2+=%%F
set /A TotalOther3+=%%G
>>"%NewFile%" echo %%A,%%B,%%C,%%D,%%D,%%E,%%F,%%G
)
)
>>"%NewFile%" echo Total,%TotalElo%,%TotalAmericanExpress%,%TotalVisa%,%TotalOther1%,%TotalOther2%,%TotalOther3%
move "%NewFile%" "lalala.csv" >nul
:EndBatch
endlocal
Я ожидал, что мой вывод lalala.csv
будет выглядеть так:
Previsão de pagamento Bandeira Valor líquido
21/05/2019 American Express R$ 17,95
21/06/2019 American Express R$ 17,95
13/05/2019 Elo R$ 1.415,08
15/05/2019 Elo R$ 1.474,79
30/05/2019 Elo R$ 100,91
04/09/2019 Elo R$ 104,73
08/07/2019 Elo R$ 87,31
03/05/2019 Elo R$ 950,61
12/09/2019 Mastercard R$ 100,20
13/08/2019 Mastercard R$ 100,20
10/06/2019 Mastercard R$ 104,36
06/05/2019 Mastercard R$ 129,56
06/06/2019 Mastercard R$ 136,96
14/10/2019 Mastercard R$ 151,00
24/06/2019 Visa R$ 104,85
14/06/2019 Visa R$ 111,01
14/08/2019 Visa R$ 111,01
15/07/2019 Visa R$ 111,01
16/10/2019 Visa R$ 127,29
09/05/2019 Visa R$ 15,05
15/08/2019 Visa R$ 163,55
16/09/2019 Visa R$ 163,55
14/06/2019 Visa R$ 90,56
Total VISA: R$ value...
Total ELO: R$ value...
Total AMERICAN EXPRESS: R$ value...
Total OHTER 1: R$ value...
etc.
Но мой результат только такой: Total,0,0,0,0,0,0
Я не нахожу ошибку.
Информация по этому вопросу относится к другой ситуации, содержащейся в этом другом вопросе:
Организация строк, столбцов и значений в CSV-файле с помощью пакетного сценария
Редактировать 1:
Мой 3.csv
таков:
Previsão de pagamento Bandeira Valor líquido
21/05/2019 American Express R$17,95
21/06/2019 American Express R$17,95
13/05/2019 Elo R$1.415,08
30/05/2019 Elo R$99.125,91
04/09/2019 Elo R$125.132,73
05/07/2019 Elo R$104,73
05/08/2019 Elo R$104,73
07/10/2019 Elo R$104,73
04/06/2019 Elo R$104,75
16/05/2019 Elo R$109,05
13/06/2019 Elo R$122,05
14/05/2019 Elo R$122,08
24/07/2019 Elo R$129,20
06/05/2019 Elo R$136,09
23/05/2019 Elo R$138,16
14/08/2019 Elo R$139,78
20/09/2019 Elo R$144,02
21/10/2019 Elo R$144,02
24/05/2019 Elo R$159,20
11/06/2019 Elo R$16,55
10/05/2019 Elo R$164,37
14/06/2019 Elo R$168,82
20/08/2019 Elo R$183,85
16/09/2019 Elo R$197,34
15/07/2019 Elo R$199,75
12/07/2019 Elo R$208,71
23/05/2019 Elo R$214,40
06/05/2019 Elo R$22,42
07/05/2019 Elo R$233,96
20/05/2019 Elo R$238,07
19/07/2019 Elo R$25,13
19/08/2019 Elo R$25,13
09/05/2019 Elo R$25,39
02/08/2019 Elo R$25,80
03/07/2019 Elo R$25,80
22/07/2019 Elo R$253,45
02/05/2019 Elo R$28,00
31/05/2019 Elo R$28,00
31/07/2019 Elo R$28,00
21/06/2019 Elo R$292,31
21/05/2019 Elo R$292,34
24/06/2019 Elo R$297,30
14/05/2019 Elo R$306,36
10/05/2019 Elo R$307,12
13/05/2019 Elo R$327,45
17/06/2019 Elo R$337,36
11/06/2019 Elo R$345,08
08/05/2019 Elo R$353,11
24/10/2019 Elo R$36,06
10/06/2019 Elo R$39,06
26/06/2019 Elo R$40,50
27/05/2019 Elo R$40,50
29/07/2019 Elo R$40,50
10/06/2019 Elo R$407,22
16/05/2019 Elo R$439,53
27/06/2019 Elo R$46,42
28/05/2019 Elo R$46,42
09/05/2019 Elo R$462,10
06/05/2019 Elo R$472,44
17/05/2019 Elo R$472,48
09/08/2019 Elo R$51,65
09/09/2019 Elo R$51,65
10/07/2019 Elo R$51,65
10/10/2019 Elo R$51,65
04/07/2019 Elo R$53,81
12/06/2019 Elo R$55,50
15/05/2019 Elo R$57,08
16/08/2019 Elo R$57,56
02/05/2019 Elo R$588,24
29/08/2019 Elo R$59,25
30/07/2019 Elo R$59,25
30/09/2019 Elo R$59,25
13/08/2019 Elo R$59,97
23/07/2019 Elo R$60,29
16/07/2019 Elo R$65,16
19/06/2019 Elo R$67,42
18/06/2019 Elo R$68,64
11/09/2019 Elo R$73,14
12/08/2019 Elo R$73,14
14/10/2019 Elo R$73,14
11/07/2019 Elo R$74,71
13/05/2019 Elo R$75,19
17/07/2019 Elo R$76,91
03/06/2019 Elo R$79,62
05/06/2019 Elo R$82,27
23/08/2019 Elo R$86,70
23/09/2019 Elo R$86,70
01/07/2019 Elo R$87,25
06/06/2019 Elo R$87,31
07/05/2019 Elo R$87,31
08/07/2019 Elo R$87,31
03/05/2019 Elo R$950,61
15/05/2019 Elo R$99.474,79
12/09/2019 Mastercard R$100,20
13/08/2019 Mastercard R$100,20
10/06/2019 Mastercard R$104,36
06/05/2019 Mastercard R$129,56
06/06/2019 Mastercard R$136,96
14/10/2019 Mastercard R$151,00
12/06/2019 Mastercard R$17,96
11/06/2019 Mastercard R$24,14
15/05/2019 Mastercard R$306,89
19/06/2019 Mastercard R$31,16
20/05/2019 Mastercard R$31,16
22/07/2019 Mastercard R$32,23
14/06/2019 Mastercard R$374,27
13/06/2019 Mastercard R$38,71
14/05/2019 Mastercard R$38,71
04/06/2019 Mastercard R$39,06
15/07/2019 Mastercard R$425,07
13/09/2019 Mastercard R$50,80
14/08/2019 Mastercard R$50,80
17/06/2019 Mastercard R$50,82
10/05/2019 Mastercard R$61,36
24/06/2019 Mastercard R$64,60
23/05/2019 Mastercard R$64,62
21/05/2019 Mastercard R$70,57
21/06/2019 Mastercard R$70,57
13/05/2019 Mastercard R$80,40
13/05/2019 Mastercard R$84,56
10/06/2019 Mastercard R$99,66
08/05/2019 Mastercard R$99.324,18
24/06/2019 Visa R$104,85
14/06/2019 Visa R$111,01
14/08/2019 Visa R$111,01
15/07/2019 Visa R$111,01
16/10/2019 Visa R$127,29
09/05/2019 Visa R$15,05
15/08/2019 Visa R$163,55
16/09/2019 Visa R$163,55
09/08/2019 Visa R$19,26
09/09/2019 Visa R$19,26
10/05/2019 Visa R$19,26
10/07/2019 Visa R$19,26
16/07/2019 Visa R$194,36
17/06/2019 Visa R$194,42
06/05/2019 Visa R$254,65
29/05/2019 Visa R$33,85
10/06/2019 Visa R$34,31
10/05/2019 Visa R$344,33
19/06/2019 Visa R$36,81
19/08/2019 Visa R$36,81
22/07/2019 Visa R$36,81
23/05/2019 Visa R$41,09
23/07/2019 Visa R$41,09
21/06/2019 Visa R$48,95
22/05/2019 Visa R$48,95
16/05/2019 Visa R$49,08
15/05/2019 Visa R$58,83
27/05/2019 Visa R$63,76
20/05/2019 Visa R$64,19
27/06/2019 Visa R$65,31
28/05/2019 Visa R$65,31
13/06/2019 Visa R$82,88
14/05/2019 Visa R$82,88
13/05/2019 Visa R$88,30
14/06/2019 Visa R$90,56