我正在尝试使用CSV
操纵传入的batch script
文件。
我尝试做两个操作。
首先,我将分隔为;
的制表符中的数据转换为分隔,并为每行添加前缀(FV1)。然后我需要操作字段(在添加FV1之后为9;)并将不需要的信息Data should be Information
移除到Information
,并在同一列中与zipcode
和City
对齐(应该拆分)进入zipcode;City
)
10007 E L TKP 1997-03-04 1200 Data should be Information 101 0 K0324-6 106494689 3 5493 204100922 Address 1 1208 30791 Sirname Lastname Address 1 1208 12345 City SE 070-3187878
我有这段代码,我可以创建;
分隔文件并添加V1; first
。但最后两部分,我无法解决。
1
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
set "inputfile=C:\Temp\test_in.txt"
set "outputfile=C:\Temp\test_out.txt"
::There should be a TAB character after the equal below
set "tab= "
set "space= "
for /f "delims= skip=1" %%A in ('findstr /rn "^" %inputfile%') do (
set ln=%%A
setlocal enableDelayedExpansion
set "ln=!ln:*:=!"
if defined ln set "ln=!ln:%tab%=;!"
set "outputdata=V1;!ln!"
:: echo !outputdata!
for /F "delims=; tokens=35" %%a in (%outputdata%) do (
set string=%%a & echo !string:%space%=;!
echo !string!)
endlocal
) >> %outputfile%