Replace specific text in csv via commandline

前端 未结 3 1594
孤街浪徒
孤街浪徒 2021-01-16 04:38

I have data in csv format that gets output from SQL Server. The data has some NULL and N.A. values written out which makes a column ch

3条回答
  •  心在旅途
    2021-01-16 05:15

    @echo off
        setlocal enableextensions enabledelayedexpansion
    
        (for /f "tokens=*" %%f in (a.csv) do if not "%%f"=="" (
                set "line=%%f"
                set "line=!line:NULL=-1!"
                set "line=!line:N.A.=-2!"
                echo(!line!
        )) > b.csv
    
        endlocal
    

    This will work if, as stated by OP, the file is in the format indicated, containing only integers, NULL and N.A., or at least it does not include special characters.

提交回复
热议问题