我已经获得了一个名为'people.csv'的CSV文件,需要将文件中的每个人导出到它自己的XAML文件中...... CSV看起来像这样
“姓名”,“职称”
“Rich Bishop”,“所有者”
“Liam Smythe”,“学徒”“Josh Middleton”,“人机混合”
我需要编写一个BAT文件,将每个名称和职位名称导出到他们自己的XAML文件中,所以我的最终结果应该是richbishop.xaml,liamsmythe.xaml等等......
XAML的输出格式:
<Grid Background="Red" x:Name="ContentPanel" Margin="12,0,12,0">
<StackPanel Margin="20" Background="Blue" PointerPressed="commonHandler">
<TextBlock x:Name="firstTextBlock" FontSize="30" >** NAME </TextBlock>
<TextBlock x:Name="secondTextBlock" FontSize="30" > JOB TITLE **</TextBlock>
</StackPanel>
</Grid>
答案 0 :(得分:1)
了解这对您有何帮助:
@echo off
for /f "skip=1 tokens=1,* delims=," %%a in (people.csv) do (
set "name=%%~a" & set "job=%%b"
setlocal enabledelayedexpansion
set namexaml=!name: =!
set job=!job:~2,-1!
echo "!name!" "!job!"
(
echo ^<Grid Background="Red" x:Name="ContentPanel" Margin="12,0,12,0"^>
echo ^<StackPanel Margin="20" Background="Blue" PointerPressed="commonHandler"^>
echo ^<TextBlock x:Name="firstTextBlock" FontSize="30" ^>!NAME!^</TextBlock^>
echo ^<TextBlock x:Name="secondTextBlock" FontSize="30" ^>!JOB!^</TextBlock^>
echo ^</StackPanel^>
echo ^</Grid^>
)>"!namexaml!.xaml"
endlocal
)
pause