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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to write data to CSV file from waveform chart

Solved!
Go to solution

Hello NI community,

 

Firstly, I would like to say thank you all for your support. I am working on a Gaussmeter to get the magnetic field density data. Successfully, I am getting data from the Gaussmeter in a waveform chart. Now, I would like to save the measured data into CSV file. I knew direct export process but for user interface, Just they have to select the path for CSV file, run the program, all the data needs to be saved in CSV file. I want the data to be saved in a csv file same as how the data is getting plotted in wave form chart.

I have one more doubt is it possible to create a CSV file from the wave form chart.

 

When I implemented the spreadsheet file into the program, it’s not working (I was not able to run the program). Could you please suggest me how to write data to CSV file and Could you please recommend any examples. 

 

Thanks & Regards

Vijay

Download All
0 Kudos
Message 1 of 19
(3,650 Views)

Sorry, no LabVIEW 2021 here, but looking at the picture shows a few unusual things that should be corrected.

 

  • You need to wire a comma as delimiter to the file write operations
  • The header should be a string array with three elements and no commas.
  • The "replace array subset is pointless. You need to form an array with three elements using "build array".
  • I would try without "transpose=true" (hard to tell where things are wired from the picture!).

 

A better and much more efficient option would be to use lowlevel file IO. Open the file before the loop, write the headers, then keep appending rows (form the array with three elements then use "array to spreadsheet string" using comma as delimiter). Close the file after the loop has completed.

0 Kudos
Message 2 of 19
(3,597 Views)

Hello Altenbach,

 

Thank you so much for your kind reply. I have changed the program according to your suggestions. I was able to get the excel file. when I tried to check the data saved in excel, just magnetic flux density alone is saved not Time. I would like to get Time along with Magnetic flux density. Could you please check the code once and let me know your suggestions for Time as well. Do I need to change the program for getting Time data and magnetic flux density data. Looking forward to hearing from you soon.

 

Thanks 

Vijay

Download All
0 Kudos
Message 3 of 19
(3,570 Views)

Hi vijay,

 


@vijay0507 wrote:

when I tried to check the data saved in excel, just magnetic flux density alone is saved not Time.


Because "magnetic flux" is the only value that you save to your file!

When you also want some timestamps in the file then you need to save them too!

 

I don't see anything related to timestamps in your VI/blockdiagram…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 19
(3,559 Views)

Hello,

 

Thank you for the reply. But I am not getting how to save the data of X axis (Time) as well. I want to save the data of both X (Time) and Y (Magnetic flux density) values in .csv file. Since X is time, it can be in arbitrary unit.

 

Could you please check previous message attached program file. I was trying but just Magnetic flux density data alone getting into csv file. I want to Flux density along with time when I run the program. Could you please suggested any ideas or reference program.

 

Thanks & Regards

Vijay

0 Kudos
Message 5 of 19
(3,528 Views)

Hello

 

I was trying to add array to the spreadsheet but not getting the Time values from the waveform chart. In waveform chart I was getting Time in sec on X-axis and Magnetic flux density mT on Y-axis. when I try to save waveform data into a .csv file. Just Y-axis data is getting saved but not X-axis data (Time).

 

Since I am new to LabVIEW, I don't have much knowledge of how to save time data along with Magnetic flux density of Y-axis. Could you please provide me your valuable suggestions.

 

Thanks 

Vijay

0 Kudos
Message 6 of 19
(3,518 Views)

Hello

 

I was trying to add array to the spreadsheet but not getting the Time values from the waveform chart. In waveform chart I was getting Time in sec on X-axis and Magnetic flux density mT on Y-axis. when I try to save waveform data into a .csv file. Just Y-axis data is getting saved but not X-axis data (Time).

 

Since I am new to LabVIEW, I don't have much knowledge of how to save time data along with Magnetic flux density of Y-axis. Could you please provide me your valuable suggestions.

 

Thanks 

Vijay

0 Kudos
Message 7 of 19
(3,517 Views)
Solution
Accepted by topic author vijay0507

 

  • The inner FOR loop makes absolutely no sense.
  • 'If "Numeric" (please give it a descriptive name!!!) is zero or negative (the default), the 2D array will be empty, If it is positive, you are duplicating exactly same values N times. Seems redundant! It seems you just randomly throwing random code at it until the wire going to the file write function is no longer broken, even if it makes no logical sense at all.
  • You are writing a header with 2 rows and three columns followed by a header with five columns and we have no idea how you want to append the measurement data.

I think you should take a step back and tell us what you are trying to do, not how you are trying to do it. Can you show us how the csv file should look like, exactly?

0 Kudos
Message 8 of 19
(3,509 Views)

Hello Altenbach,

 

Thank you so much for your reply. Actually, I am working on a Gaussmeter to get Magnetic flux density data along with time. Successfully, I am getting data from the Gaussmeter in waveform chart, as you can see in attached picture. Now I want to save data X-axis (Time [s]) and Y-axis Magnetic flux density (mT) into .csv file. I knew direct export data to excel file process but I want to create and write data into a .csv file to my program when I run and also it includes Time X-axis along with flux density data Y-axis, so I would like to write a measured data directly into .csv file.

 

For your reference I am attaching the Graph and want the excels file in the attached formate. Looking forward to hear from you soon.

 

Thanks

Vijay

0 Kudos
Message 9 of 19
(3,503 Views)

Hello Altenbach,

 

Thank you so much for your reply. Actually, I am working on a Gaussmeter to get Magnetic flux density data along with time. Successfully, I am getting data from the Gaussmeter in waveform chart, as you can see in attached picture. Now I want to save data X-axis (Time [s]) and Y-axis Magnetic flux density (mT) into .csv file. I knew direct export data to excel file process but I want to create and write data into a .csv file to my program when I run and also it includes Time X-axis along with flux density data Y-axis, so I would like to write a measured data directly into .csv file.

 

For your reference, I am attaching the Graph and want the .csv file in the attached format (exported from graph). Looking forward to hear from you soon.

 

Thanks

 

Vijay 

Download All
0 Kudos
Message 10 of 19
(3,502 Views)