WARNING:
THIS CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED; THE AUTHOR DISCLAIMS ALL LIABILITY FOR ANY DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR STORE DISRUPTIONS ARISING FROM ITS USE.
Scot Ranney • March 01, 2024
1. Page Items: assign "http headers" item to the page (batch report template usually)
2. Create a header:
SMT code using tab delim:
<mvt:assign name="l.delim" value="asciichar(9)" /> <mvt:assign name="l.lf" value="asciichar(10)" /> <mvt:foreach iterator="line" array="data"> <mvt:eval expr="l.row1_data $ l.delim $ l.row2_data $ l.delim $ l.row3_data $ l.lf" /> </mvt:foreach>
SMT code using comma delim and miva csv encoding:
<mvt:assign name="l.delim" value="','" /> <mvt:assign name="l.lf" value="asciichar(10)" /> <mvt:foreach iterator="line" array="data"> <mvt:assign name="l.line" value="miva_csv_encode(l.row1_data,l.delim) $ l.delim $ miva_csv_encode(l.row2_data,l.delim) $ l.delim $ miva_csv_encode(l.row3_data,l.delim) $ l.lf" /> <mvt:eval expr="l.line" /> </mvt:foreach>
CSV Headers:
You can manually put a header line on top or not, doesn't really matter if your columns are in the right order and your parsing script needs them in that order. Remember to skip the first line when importing if the file is using a header.
header batch