Difference between revisions of "Component: CSV Read/Write (File)"

From Flowcode Help
Jump to navigationJump to search
 
(7 intermediate revisions by 2 users not shown)
Line 22: Line 22:
  
 
==Detailed description==
 
==Detailed description==
 +
 +
  
  
Line 48: Line 50:
  
 
==Examples==
 
==Examples==
 +
 +
  
  
Line 63: Line 67:
 
Simple example file to generate a two column CSV file that can be loaded into Microsoft Excel or LibreOffice Math.
 
Simple example file to generate a two column CSV file that can be loaded into Microsoft Excel or LibreOffice Math.
  
CSV Component used with Embedded -> File SD component: {{Fcfile|CSVTest.fcfx|CSV Test}}
+
The CSV Read/Write component is for simulation or App Developer.
  
CSV Component used with Embedded -> File RPI component: {{Fcfile|CSVTestRPI.fcfx|CSV Test RPI}}
+
For an embedded CSV read write see the [[Component:_Embed_File_(File)|File component]]
  
 
CSV Component used with App Developer -> File component: {{Fcfile|CSVTestAD.fcsx|CSV Test AD}}
 
CSV Component used with App Developer -> File component: {{Fcfile|CSVTestAD.fcsx|CSV Test AD}}
Line 72: Line 76:
 
The component requires linking to a File component to provide access to the file system for simulation and runtime, this could be the File SD, File RPI or File AppDeveloper components.
 
The component requires linking to a File component to provide access to the file system for simulation and runtime, this could be the File SD, File RPI or File AppDeveloper components.
  
==Macro reference==
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CloseFile'''
 
|-
 
| colspan="2" | Closes the file and finishes off any pending writes ready for use in an external application. 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
  
  
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
+
==Macro reference==
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SequentialReadString'''
 
|-
 
| colspan="2" | Reads the contents of a cell as a string. Automatically moved to the next data cell after a read. 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AddString'''
 
|-
 
| colspan="2" | Adds a string to the CSV followed by a comma. This will form a single column of data in the CSV file. 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
 
| width="90%" | data
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadAsString'''
 
|-
 
| colspan="2" | Reads the contents of a cell as a string 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Column
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Row
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SequentialReadNumber'''
 
|-
 
| colspan="2" | Reads the contents of a cell as a number. Automatically moved to the next data cell after a read. 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-f32-icon.png]] - FLOAT
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
  
 +
===AddNumber===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 172: Line 99:
  
  
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
+
===AddString===
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadAsNumber'''
 
|-
 
| colspan="2" | Reads the contents of a cell as a number. 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Column
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Row
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-f32-icon.png]] - FLOAT
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetSequentialIndex'''
 
|-
 
| colspan="2" | Sets the index for sequential reads. Index is automatically reset to 0 after a file open. 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Index
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''OpenFile'''
 
|-
 
| colspan="2" | Creates or opens a file ready for streaming data. If the file already exists then the contents will be deleted and the file started again from scratch. Returns 1 if file found and opened. 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
 
| width="90%" | Filename
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL
 
| width="90%" | Erase
 
|-
 
| colspan="2" | 0=Append existing data, 1=Reset file data 
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-bool-icon.png]] - BOOL
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''NextRow'''
 
|-
 
| colspan="2" | Move to the next row in the file 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
 
 
 
 
==Property reference==
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | LinkTo
 
|-
 
| colspan="2" |  
 
|}==Macro reference==
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CloseFile'''
 
|-
 
| colspan="2" | Closes the file and finishes off any pending writes ready for use in an external application. 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SequentialReadString'''
 
|-
 
| colspan="2" | Reads the contents of a cell as a string. Automatically moved to the next data cell after a read. 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 309: Line 118:
  
  
 +
===CloseFile===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadAsString'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CloseFile'''
 
|-
 
|-
| colspan="2" | Reads the contents of a cell as a string 
+
| colspan="2" | Closes the file and finishes off any pending writes ready for use in an external application. 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Column
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Row
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SequentialReadNumber'''
 
|-
 
| colspan="2" | Reads the contents of a cell as a number. Automatically moved to the next data cell after a read. 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-f32-icon.png]] - FLOAT
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AddNumber'''
 
|-
 
| colspan="2" | Adds a number to the CSV followed by a comma. This will form a single column of data in the CSV file. 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
 
| width="90%" | data
 
 
|-
 
|-
| colspan="2" |  
 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
Line 363: Line 132:
  
  
 +
===NextRow===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadAsNumber'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''NextRow'''
 
|-
 
|-
| colspan="2" | Reads the contents of a cell as a number. 
+
| colspan="2" | Move to the next row in the file 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Column
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Row
 
 
|-
 
|-
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-f32-icon.png]] - FLOAT
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetSequentialIndex'''
 
|-
 
| colspan="2" | Sets the index for sequential reads. Index is automatically reset to 0 after a file open. 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Index
 
|-
 
| colspan="2" |  
 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
Line 404: Line 146:
  
  
 +
===OpenFile===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 427: Line 170:
  
  
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
+
===ReadAsNumber===
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''NextRow'''
 
|-
 
| colspan="2" | Move to the next row in the file 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
 
 
 
 
==Property reference==
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | LinkTo
 
|-
 
| colspan="2" |  
 
|}==Macro reference==
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CloseFile'''
 
|-
 
| colspan="2" | Closes the file and finishes off any pending writes ready for use in an external application. 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SequentialReadString'''
 
|-
 
| colspan="2" | Reads the contents of a cell as a string. Automatically moved to the next data cell after a read. 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AddString'''
 
|-
 
| colspan="2" | Adds a string to the CSV followed by a comma. This will form a single column of data in the CSV file. 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
 
| width="90%" | data
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadAsString'''
 
|-
 
| colspan="2" | Reads the contents of a cell as a string 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Column
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Row
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SequentialReadNumber'''
 
|-
 
| colspan="2" | Reads the contents of a cell as a number. Automatically moved to the next data cell after a read. 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-f32-icon.png]] - FLOAT
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AddNumber'''
 
|-
 
| colspan="2" | Adds a number to the CSV followed by a comma. This will form a single column of data in the CSV file. 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
 
| width="90%" | data
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 577: Line 194:
  
  
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
+
===ReadAsString===
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetSequentialIndex'''
 
|-
 
| colspan="2" | Sets the index for sequential reads. Index is automatically reset to 0 after a file open. 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Index
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''OpenFile'''
 
|-
 
| colspan="2" | Creates or opens a file ready for streaming data. If the file already exists then the contents will be deleted and the file started again from scratch. Returns 1 if file found and opened. 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
 
| width="90%" | Filename
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL
 
| width="90%" | Erase
 
|-
 
| colspan="2" | 0=Append existing data, 1=Reset file data 
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-bool-icon.png]] - BOOL
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''NextRow'''
 
|-
 
| colspan="2" | Move to the next row in the file 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
 
 
 
 
==Property reference==
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | LinkTo
 
|-
 
| colspan="2" |  
 
|}==Macro reference==
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CloseFile'''
 
|-
 
| colspan="2" | Closes the file and finishes off any pending writes ready for use in an external application. 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SequentialReadString'''
 
|-
 
| colspan="2" | Reads the contents of a cell as a string. Automatically moved to the next data cell after a read. 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AddString'''
 
|-
 
| colspan="2" | Adds a string to the CSV followed by a comma. This will form a single column of data in the CSV file. 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
 
| width="90%" | data
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 714: Line 218:
  
  
 +
===SequentialReadNumber===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 727: Line 232:
  
  
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
+
===SequentialReadString===
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AddNumber'''
 
|-
 
| colspan="2" | Adds a number to the CSV followed by a comma. This will form a single column of data in the CSV file. 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
 
| width="90%" | data
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadAsNumber'''
 
|-
 
| colspan="2" | Reads the contents of a cell as a number. 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Column
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Row
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-f32-icon.png]] - FLOAT
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetSequentialIndex'''
 
|-
 
| colspan="2" | Sets the index for sequential reads. Index is automatically reset to 0 after a file open. 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Index
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''OpenFile'''
 
|-
 
| colspan="2" | Creates or opens a file ready for streaming data. If the file already exists then the contents will be deleted and the file started again from scratch. Returns 1 if file found and opened. 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
 
| width="90%" | Filename
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL
 
| width="90%" | Erase
 
|-
 
| colspan="2" | 0=Append existing data, 1=Reset file data 
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-bool-icon.png]] - BOOL
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''NextRow'''
 
|-
 
| colspan="2" | Move to the next row in the file 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
 
 
 
 
==Property reference==
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | LinkTo
 
|-
 
| colspan="2" |  
 
|}==Macro reference==
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CloseFile'''
 
|-
 
| colspan="2" | Closes the file and finishes off any pending writes ready for use in an external application. 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 864: Line 246:
  
  
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
+
===SetSequentialIndex===
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AddString'''
 
|-
 
| colspan="2" | Adds a string to the CSV followed by a comma. This will form a single column of data in the CSV file. 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
 
| width="90%" | data
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadAsString'''
 
|-
 
| colspan="2" | Reads the contents of a cell as a string 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Column
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Row
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SequentialReadNumber'''
 
|-
 
| colspan="2" | Reads the contents of a cell as a number. Automatically moved to the next data cell after a read. 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-f32-icon.png]] - FLOAT
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AddNumber'''
 
|-
 
| colspan="2" | Adds a number to the CSV followed by a comma. This will form a single column of data in the CSV file. 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
 
| width="90%" | data
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadAsNumber'''
 
|-
 
| colspan="2" | Reads the contents of a cell as a number. 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Column
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Row
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-f32-icon.png]] - FLOAT
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 975: Line 263:
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''OpenFile'''
 
|-
 
| colspan="2" | Creates or opens a file ready for streaming data. If the file already exists then the contents will be deleted and the file started again from scratch. Returns 1 if file found and opened. 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
 
| width="90%" | Filename
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL
 
| width="90%" | Erase
 
|-
 
| colspan="2" | 0=Append existing data, 1=Reset file data 
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-bool-icon.png]] - BOOL
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''NextRow'''
 
|-
 
| colspan="2" | Move to the next row in the file 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
 
 
  
  

Latest revision as of 10:25, 20 October 2023

Author Matrix TSL
Version 1.0
Category File


CSV Read/Write component

A component to simplify the task of creating and dumping data to a CSV file that can be loaded into Microcoft Excel or LibreOffice Math to create nice charts and graphs. Requires one of the File components to provide access to the file system.

Component Source Code

Please click here to download the component source project: FC_Comp_Source_CSV_Writer.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_CSV_Writer.fcfx

Detailed description

No detailed description exists yet for this component

Examples

Simple example file to generate a two column CSV file that can be loaded into Microsoft Excel or LibreOffice Math.

The CSV Read/Write component is for simulation or App Developer.

For an embedded CSV read write see the File component

CSV Component used with App Developer -> File component: FC6 Icon.png CSV Test AD


The component requires linking to a File component to provide access to the file system for simulation and runtime, this could be the File SD, File RPI or File AppDeveloper components.


Macro reference

AddNumber

Fc9-comp-macro.png AddNumber
Adds a number to the CSV followed by a comma. This will form a single column of data in the CSV file. 
Fc9-f32-icon.png - FLOAT data
 
Fc9-void-icon.png - VOID Return


AddString

Fc9-comp-macro.png AddString
Adds a string to the CSV followed by a comma. This will form a single column of data in the CSV file. 
Fc9-string-icon.png - STRING data
 
Fc9-void-icon.png - VOID Return


CloseFile

Fc9-comp-macro.png CloseFile
Closes the file and finishes off any pending writes ready for use in an external application. 
Fc9-void-icon.png - VOID Return


NextRow

Fc9-comp-macro.png NextRow
Move to the next row in the file 
Fc9-void-icon.png - VOID Return


OpenFile

Fc9-comp-macro.png OpenFile
Creates or opens a file ready for streaming data. If the file already exists then the contents will be deleted and the file started again from scratch. Returns 1 if file found and opened. 
Fc9-string-icon.png - STRING Filename
 
Fc9-bool-icon.png - BOOL Erase
0=Append existing data, 1=Reset file data 
Fc9-bool-icon.png - BOOL Return


ReadAsNumber

Fc9-comp-macro.png ReadAsNumber
Reads the contents of a cell as a number. 
Fc9-u16-icon.png - UINT Column
 
Fc9-u16-icon.png - UINT Row
 
Fc9-f32-icon.png - FLOAT Return


ReadAsString

Fc9-comp-macro.png ReadAsString
Reads the contents of a cell as a string 
Fc9-u16-icon.png - UINT Column
 
Fc9-u16-icon.png - UINT Row
 
Fc9-string-icon.png - STRING Return


SequentialReadNumber

Fc9-comp-macro.png SequentialReadNumber
Reads the contents of a cell as a number. Automatically moved to the next data cell after a read. 
Fc9-f32-icon.png - FLOAT Return


SequentialReadString

Fc9-comp-macro.png SequentialReadString
Reads the contents of a cell as a string. Automatically moved to the next data cell after a read. 
Fc9-string-icon.png - STRING Return


SetSequentialIndex

Fc9-comp-macro.png SetSequentialIndex
Sets the index for sequential reads. Index is automatically reset to 0 after a file open. 
Fc9-u16-icon.png - UINT Index
 
Fc9-void-icon.png - VOID Return


Property reference

Fc9-prop-icon.png Properties
Fc9-type-16-icon.png LinkTo