From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Write Continuous Data to Spreadsheet (CSV) with Headers

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Download All

Description

Deprecation notice

This example was written with LabVIEW 2012 and uses the Write to Spreadsheet File.vi which has since been replaced with the Write Delimited Spreadsheet.vi. This example should still run and serve as a tool for learning how to write CSV data with headers. However, if you are building a new application, it is suggested that you update these functions to the supported Write Delimited Spreadsheet.vi function.

 

Overview

This example shows how to use the Write to Spreadsheet VI to write data to a Comma Separated Value (CSV) spreadsheet file which can be read in Microsoft Excel.

 

 

Description

This VI uses the Write to Spreadsheet VI to write a CSV file.  The code is separated into four parts.  First, the header information is written to the CSV file.  Next the channel names are written to the CSV file.  Lastly, inside the While Loop, the Random Number (0-1) VI is used to simulate data generation and then these random values are written to the CSV file.

 

 

Requirements

LabVIEW 2012 (or compatible)

 

 

Steps to Implement or Execute Code

1. Choose where you would like to store the file

2. Fill out the Header Info array with the header information for your output file.

3. Fill out the Channel Names array with the names of your data channels

4. Determine how many channels of data you want to write and how many values will be written per channel

5. Run the VI

6. Navigate to the file path you provided to see the CSV file the VI created

 

 

Additional Information or References

Front Panel

FP.PNG

 

Block Diagram

BD.PNG

 

 CSV file in Microsoft Excel

CSV File.PNG

 

 

 

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
CurtHarrington
Member
Member
on

Very simple and easy to follow.  Awesome

Meins321
Member
Member
on

yes and on top of easy and nice to follow he describes the entire input, thus gives you an example on how to "include it" inside your vi's

SmallFox
Member
Member
on

Hueter ,你好!

请问 Header Info 能改成自己编辑的么?

‘’Header Info‘’ can change it into my own?

Expect your answer.

Thank you!

T@nvi143
Member
Member
on

Hello, Why in my CSV file , All Channel are not distributed in new row. All of them are in first row together. Thanks

 

 

Desktop.png

shivik89
Member
Member
on

Hello my labview is not seeing some of the Vi's where can I download them?

sewadork
Member
Member
on

Hey, just a little update.

If you have the same problem as T@nvi143 than use a " ; " instead of a simple comma as the delimiter.