LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing to spreadsheet

Solved!
Go to solution

I tried the little snippet you posted following my suggestion that you "experiment" with getting the Write to Spreadsheet function to work.  Oops, your code threw an error (possibly because you never finished it).  At the risk of stifling your initiative, try this;

Trivial CSV Demo.png

You'll notice I added a "Proof of Concept" three-function "Read it back and prove to me the data are there" as an Extra Credit Exercise.  If you can get your code to generate data as a 1 or 2D array of reals, this pretty trivial code will write it.

 

BS

Message 21 of 26
(1,333 Views)

Thank you Bob. I have been "playing" with it for quite some time. I am able to put the for loops together and write to my spread sheet. My problem is writing from the DAQmx Read (data terminal), to the write to spreadsheet. I attached a screenshot of what I have been playing with.

0 Kudos
Message 22 of 26
(1,326 Views)

The "," was supposed to be attached to the delimiter on the Write to spreadsheet. Not sure how I moved that during screenshot.

0 Kudos
Message 23 of 26
(1,324 Views)
Solution
Accepted by topic author ceilingwalker

1 channel 1 sample puts out a scalar value.  Hover over the broken wire and it will tell you error, that the source is a scalar, and the sink is either a 1-D array of double or a 2-D array of double (depending on if you use the 1-D or 2-D array input.)

 

Just use build array to turn the scalar into a 1-D array and wire it into the 1-D array input.

 

Be sure to wire a True constant to the Append? input of the Write to Spreadsheet file, otherwise your single value will constantly overwrite itself.

Message 24 of 26
(1,319 Views)
Solution
Accepted by topic author ceilingwalker

Now that we can see your code, it becomes A LOT easier to spot the issue.  Your problem is that you are reading a single data point from the DAQ.  Therefore, the DAQmx Read outputs a SCALER.  The scaler is not compatible with an array.  Luckily, the solution is really simple.  Build an array.  You can do this with a FOR loop and autoindex the output (allowing you to write more samples at once, reducing the time it takes to write the data) or you can just use Build Array reduced to a single input.  This will turn your scaler into an array with a single element.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 25 of 26
(1,314 Views)

Thanks a lot guys, that did it. I can't believe I spent all that time yesterday and today and couldn't figure this out.

0 Kudos
Message 26 of 26
(1,310 Views)