LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help creating Spreadsheet File properly

Solved!
Go to solution

Hello everyone.

 

I'm creating a program which has to provide a spreadsheet file (a .csv file to be opened on Excel) with a few values recorded as an output after the program runs.
I have 3 parameters which should be shown as:


Parameter 1            Parameter 2             Parameter 3

Value                       Value                        Value

 

Aswell as values of average energy consumption for each speed at which the compressor im working with can operate, which should be shown as:

 

Speed [RPM]          EC [W]

4500                       Value

4200                       Value

...                            ...

1800                       Value

 

I'm able to create the .csv file with the values I need, but if you open the file, the values are all sorted weirdly (not separated by column).

I have tried many different approaches to this, but I can't get them to be sorted how I need them to.

 

I have attached an example VI that shows how I'm currently implementing this function, aswell as 2 .csv files to be opened with Excel. The first file shows how the output spreadsheet file looks when you run the VI and the second file shows how I want it to look, or at least something closer to that.

 

To use the example VI, simply run it, select a file directory and save with any name with .csv on the end. Then open the file with Excel.

 

This is my first time using this forum, so if I need to provide any further information, please let me know.
Thanks for the help!

0 Kudos
Message 1 of 5
(1,495 Views)
Solution
Accepted by topic author Pexavi

1. It looks like you are in a location that uses the comma as the decimal separator.  This kind of makes a CSV illogical.

2. You are actually using a tab to separate your values.

 

So based on those, save your file as a txt instead and Excel will still open it up, using the tab as the column separators.

 

Additionally, you really need to watch how you are mixing arrays and strings.

 

I don't have the time to do a clean up of your diagram, but I would highly recommend against using the Write Spreadsheet File and just use the actual Write Text File.  You can do all of the formatting of the data before that.


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
0 Kudos
Message 2 of 5
(1,475 Views)

On top of what Crossrulz said I see you are also enclosing every line in quotes

 

I think that might also be confusing Excel and treating it as one big cell when it imports it.

 

I removed the quotes and used Tab as the Delimiter when importing it and it looks like this in Excel

 

E1Capture.PNG

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 5
(1,466 Views)
Solution
Accepted by topic author Pexavi

Maybe something like this?

 

(And yes, save it as *.txt, the open it in excel. Since you only have integers, you can change the delimiter for all "array to spreasheet string" function to comma and name the file *.csv, but be aware that if your localization also uses comma as decimal delimiter for numerics, you need to change a few things)

 

altenbach_0-1615829758521.png

 

 

As others have said, you really need to familiarize yourself with format codes and datatypes. "%s" is not a format for numeric arrays and if you have integers, you should not have anything orange. I would also recommend to get away from formula nodes. You are just overcomplicating things here. Use array diagram constants instead of all these loose scalars!

Message 4 of 5
(1,439 Views)

Thank you for the advices and solutions. 

0 Kudos
Message 5 of 5
(1,351 Views)