[Windows Bash Script] convert csv to html table

source: How to find and replace a string in text file using batch file

just replace “,” with html table tag.

@echo off
setlocal enabledelayedexpansion
set txtfile=%~1
set newfile=Output.html
if exist "%newfile%" del /f /q "%newfile%"
echo ^<table border='1'^> >> %newfile%
for /f "tokens=*" %%a in (%txtfile%) do (
   set newline=%%a
   set newline=^<tr^>^<td^>!newline:,=^</td^>^<td^>!^</td^>^</tr^>
   echo !newline! >> %newfile%
)
echo ^</table^> >> %newfile%
This entry was posted in Windows Bash Script. Bookmark the permalink.

One Response to [Windows Bash Script] convert csv to html table

Comments are closed.