【发布时间】:2012-03-12 21:01:51
【问题描述】:
根据我在此处发布的另一个问题,我能够使该脚本的大部分工作,但我不知道如何更改选择对象的格式。谷歌一直没有帮助。
$head = @'
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Current Conditions</title>
</head>
<body style="background-color:#EEEEEE">
<h3 style="margin:0;padding-bottom:3px">Current Conditions at
'@
$1 = @'
</h3>
<p style="margin:0;padding-bottom:0px"><b>Dewpoint: </b>
'@
$2 = @'
</p>
<p style="margin:0;padding-bottom:0px"><b>Temperature: </b>
'@
$3 = @'
</p>
<p style="margin:0;padding-bottom:3px"><b>Humidity: </b>
'@
$end = @'
</p>
</body>
</html>
'@
$info = import-csv 1-pastweek.csv
$time = $info | select -last 1 Time
$temp = $info | select -last 1 Temp
$humid = $info | select -last 1 Humid
$dewpt = $info | select -last 1 Dewpt
$head + $time + $1 + $dewpt + $2 + $temp + $3 + $humid + $end | out-file -encoding "UTF8" current.html
这确实有效,但 html 输出的格式包括来自 CSV 的标头信息,我不知道如何解决它。
Current Conditions at @{TIME=03/12/2012 15:32:22}
Dewpoint: @{DEWPT=62.7}
Temperature: @{TEMP=71.9}
Humidity: @{HUMID=74.4}
关于如何让 @{HEADER } 消失的任何想法。我只想要实际数据。
【问题讨论】:
标签: html powershell csv