Created
July 19, 2018 16:29
-
-
Save awwsmm/672921b09f60ae249cf3b18b9f539a4b to your computer and use it in GitHub Desktop.
Add constant columns to CSV with batch script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal enabledelayedexpansion | |
set row=0 | |
set inFile=merged.csv | |
set outFile=final.csv | |
if exist "%outFile%" del "%outFile%" | |
>%outFile% ( | |
for /f "tokens=1,* delims=," %%A in (%inFile%) do ( | |
set /A row+=1 | |
set time=%%A | |
set data=%%B | |
REM : edit column headers and values here | |
set head=machine,label | |
set body=0,inlet-sparger | |
if !row! lss 2 ( | |
REM : I have no idea why this needs to be separated | |
REM : ...but it has to, or it doesn't work | |
echo | set /p=!time! | |
echo | set /p=,!head!, | |
echo !data! | |
) else ( | |
echo !time!,!body!,!data! | |
) | |
) | |
) | |
if exist "%inFile%" del "%inFile%" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment