node-red/nodes/core/parsers/70-CSV.html

68 lines
2.8 KiB
HTML

<!--
Copyright 2014 IBM Corp.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<script type="text/x-red" data-template-name="csv">
<div class="form-row">
<label for="node-input-temp"><i class="fa fa-list"></i> Columns</label>
<input type="text" id="node-input-temp" placeholder="A,B,C,D">
</div>
<div class="form-row">
<label for="node-input-sep"><i class="fa fa-chevron-right"></i> Separator</label>
<input type="text" id="node-input-sep" placeholder=','>
</div>
<!-- <div class="form-row">
<label for="node-input-quo"><i class="fa fa-tag"></i> Escape</label>
<input type="text" id="node-input-quo" placeholder='"'>
</div> -->
<br/>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div id="node-input-tip" class="form-tips">Tip: you can use "\t" for tab separator.</div>
</script>
<script type="text/x-red" data-help-name="csv">
<p>A function that parses the <b>msg.payload</b> to convert csv to/from a javascript object. Places the result in the payload.</p>
<p>If the input is a string it tries to parse it as CSV and creates a javascript object.</p>
<p>If the input is a javascript object it tries to build a CSV string.</p>
<p>A columns template MUST be specified that contains the ordered list of column headers. For csv input these become the property names.
For csv output these specify the properties to extract from the object and the order for the csv.</p>
<p><b>Note:</b> the columns should always be specified comma separated - even if another separator is chosen for the data.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('csv',{
category: 'function',
color:"#DEBD5C",
defaults: {
name: {value:""},
sep: {value:',',required:true},
//quo: {value:'"',required:true},
temp: {value:"",required:true}
},
inputs:1,
outputs:1,
icon: "arrow-in.png",
label: function() {
return this.name||"csv";
},
labelStyle: function() {
return this.name?"node_label_italic":"";
}
});
</script>