07-26-2023 07:10 AM
I am reading data from the scopes connected to the PXI from channels 0,1,2, and 3 and write it to the csv file using write delimited spreadsheet vi. Now I want to add value but not from the scope, the rather constant - like Frequency. What I wan to achieve is in each row of an additional column have the value of the frequency that corresponds to the measurements. Now it writes in the first row my frequency and the rest is 0. If I put condition with 2 values for frequency, fin the first row it writes first frequency and then all zeros; then when the values changes to the second value of the frequency , it writes second value of my frequency and then all zeros again. How is it possible to change so I have a value at each row? Thank you
07-26-2023 03:55 AM
Hello. I am wondering how I can write a header to the data? I am getting data (csv file) from PXI measurements. Basically I have a list with different frequencies in XML file and the program runs through all these different conditions. But in the end I get 1 file and I don't know which value corresponds to which frequency. How is is possible to add a frequency column with each frequency corresponding to each row? Thank you
07-26-2023 04:56 AM
Hi Lily,
@LilySamchuk wrote:
I am getting data (csv file) from PXI measurements. … How is is possible to add a frequency column with each frequency corresponding to each row?
Add one more column to your CSV-formatted data containing the "frequency"!
Or store your data in a TDMS file and add the frequency setting as property to the channel/group…
07-26-2023 07:31 AM
Hi Lily,
you know we cannot edit/debug/run images in LabVIEW?
@LilySamchuk wrote:
What I wan to achieve is in each row of an additional column have the value of the frequency that corresponds to the measurements. Now it writes in the first row my frequency and the rest is 0.
Right now you build a 2D array from 4 1D arrays of (most probably) a lot of values and an additional 1D array containing exactly one element - and you wonder why the additional column only contains one useful value!?
Suggestion: instead of creating an array of exactly one value you should init an array of "frequency" value sof the same size as your other arrays. There's an InitArray function…
What's the point of a FOR loop iterating just once?
Why don't you use AutoCleanup to straighten the wires?
07-26-2023 07:38 AM
When you are learning LabVIEW, you should type ^H to turn on LabVIEW Help so that whenever you hover your mouse over a LabVIEW function such as "Write Delimited Spreadsheet", the "Help" for that function pops up. Click on "Detailed Help" and you will learn even more about the function.
In particular, Write Delimited Spreadsheet is designed to have rows represent samples and columns represent "channels". So if you sample 4 channels from a Scope as a 1D WDT per channel, if you Index Array with the 4 channels using the Y data from the Waveform, your 2D Array will have rows as channels and columns as samples. That's the first "problem" -- you want samples X channels, not channels X samples.
Side note -- one of my earliest posts on the Forum when I was learning LabVIEW I used an Index Array with 0, 1, 2, 3 as the indices, as you did. Someone kindly pointed out that I don't need to wire the indices if they are sequential from 0 -- it saves a lot of time and tedium if you have 10 rows ...
Do you know how to change a 2D Array of channels X samples into a 2D Array of samples X columns? [Hint -- look at the functions on the Array palette].
Now you are ready to add the frequency. Suppose you have one row (for the first sample) and a frequency of 100, and you wanted to write the 1000 samples for that channel + the 1 frequency, but do it "all at once". How would you "combine" the 1000 samples and the 1 frequency?
Does each Channel (row) have the same Frequency, or do you have 4 different frequencies, one for each channel? If they are all different, how do you combine the "Samples" and "Frequency" data for each channel?
If you've followed me so far, you should now have an array of 4 channels consisting of 1000 samples + 1 frequency, which you can now write as a Delimited Spreadsheet that will have 4 X 1001 entries.
Give it a try.
Bob Schor
07-26-2023 08:32 AM
This question was answered in your "Log data to CSV File" post. Please don't post the same question twice.
Bob Schor
07-27-2023 02:42 AM
All channels have the same frequency. But I still don't know how to add an extra column with a frequency
07-27-2023 03:08 AM
Hi Lily,
@LilySamchuk wrote:
But I still don't know how to add an extra column with a frequency
After so many explanations?
You still don't have an idea of how to prepend an element (aka "frequency") to an array (aka "samples of one channel")? Not a single idea???
07-27-2023 08:05 AM
Now that @GerdW has combined your two "posts of the same question", if you read back about 4 replies to find the long one I wrote, I think I try to teach you exactly how to add a final Frequency entry for each Sample of 4 channels. Please read it carefully.
Bob Schor