我有一个文本文件,其中包含 PBX 的电话长途交换信息。输入文件包含:
sourceNPA,srcNNX,DestinationNPA,destNNX
954,327,954,201
954,327,954,202
954,327,954,203
954,327,954,210
954,327,954,212
954,327,954,213
954,327,954,214
etc...
出于公司政策原因(不仅仅是因为我不是编码员),我只能使用 VBS 或 Windows 批处理。我希望手动完成这些,但有 43000 或更多要转换为范围。
我需要读取给定文本文件的每一行,查看 dNPA 和 dNXX(每行中的最后两个 arg)是否连续,如果是,请确定范围,以便输入列表在输出中如下所示:
954,327,954,201,203
954,327,954,210,210
954,327,954,212,214
etc...
我已经尝试研究数组的使用并尝试将单行读取到临时文件中,但这必须有一个技巧。
我一直在修修补补,但几乎没有什么可展示的:
@echo off
setlocal enabledelayedexpansion
set lineNumber=1
if exist outputFile.txt del outputFile.txt
for /f "tokens=1-6 delims=,;" %%a in (inputFile.txt) do call :process %%a %%b %%c %%d
:EOF
:process
set line!linenumber!SrcNPA=%1
set line!linenumber!SrcNNX=%2
set line!linenumber!destNPA=%3
set line!linenumber!destNNX=%4
REM then intended to compare the values but I'm stuck
REM I want to compare the last arugment of each line to the same
REM same argument in the next line read, and if its sequential
REM then set the start the range and when the comaparison is no longer
REM consecutive set the top of the range andn then write that range to output
set /a lineNumber+=1