mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
68 lines
2.7 KiB
HTML
68 lines
2.7 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="icon-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="icon-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="icon-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="icon-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>
|