我有一个csv文件,我想用fmpp(freemarker)进行转换.第一列是一个长值(自1970年1月1日以来的毫秒),我想将其转换为日期并将其格式化为datetime.
src格式:
timeStamp,elapsed,label,responseCode,threadName,dataType,success,bytes,URL,Latency
1319115474244,40142,Login,200,Login 1-2,text,true,862184,http://localhost:8080/xxx,5378
Run Code Online (Sandbox Code Playgroud)
理想的目标格式:
timeStamp;elapsed;label;responseCode;threadName;dataType;success;bytes;URL;Latency
20.12.2011 13:45;40142;Login;200;Login 1-2;text;true;862184;http://localhost:8080/xxx;5378
Run Code Online (Sandbox Code Playgroud)
我的(运行)模板:
<#list csv.headers as h>${h}<#if h_has_next>;</#if></#list>
<#list csv as row>
<#list csv.headers as h><#if h_index == 0>Do the date magic<#else>${(row[h]!"N/A")?string}</#if>$<#if h_has_next>;</#if></#list>
</#list>
Run Code Online (Sandbox Code Playgroud)
对于第0列,我想进行转换.我不想写一个包含日期的新模型.我的问题是,这可以在模板中完成,而无需修改freemarker或fmpp.
有任何想法吗?
有谁知道FMPP文本文件预处理器的 Python 等价物?
跟进:我正在阅读文档并查看给出建议的示例。只是为了扩展。我对 FMPP 的使用是读入数据文件 (csv) 并根据该数据使用多个模板以在 html 中创建所有链接到主索引的多页报告。