我在使用 .bat 將檔案 tsv 轉換為檔案 csv 時遇到了一些麻煩。問題是當我使用制表符和空格更改資料時無法轉換
我目前的來源
setlocal disableDelayedExpansion
set OUT_DIR1=%1
set input=%OUT_DIR1%\%2
set output=%OUT_DIR1%\%3
set IN_DIR=%4
type %IN_DIR%\*.tsv > %OUT_DIR1%\result.tsv
>%output% (
for /F "tokens=* delims=" %%a in (%input%) do (
set "line="
setlocal enableDelayedExpansion
for %%b in (%%a) do set "line=!line!,%%b"
echo !line:~1!
endlocal
)
)
我的輸入檔案
0001 abc de mo1 abc
0001 a bc de mo2 abc
0001 abc de mo3 a bc
0001 a bc de mo4 a bc
我想要的輸出
0001,abc,demo1,abc
0001,abc,demo2,abc
0001,abc,demo3,abc
0001,abc,demo4,abc
請幫我!!!!!!!!!!!!!!!!!!!
uj5u.com熱心網友回復:
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
rem The following settings for the source directory, destination directory,
rem filename, output filename are names
rem that I use for testing and deliberately include names which include spaces to make sure
rem that the process works using such names. These will need to be changed to suit your situation.
SET "sourcedir=u:\your files"
SET "destdir=u:\your results"
SET "filename1=%sourcedir%\q72797128.txt"
SET "outfile=
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/497598.html
上一篇:在Javascript中,在將宣告的類作為引數傳遞給Object.getPrototypeOf時,結果參考父類。這是為什么?
