LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save array (with different elements in cells) to file

Solved!
Go to solution

Hello,

 

In the attached VI, I am trying to save the array given in the Input Array to a file, that can then be read in at a later time and when read, generate the same array as the Input Array. 

 

The current VI, save the data in a skewed format and I cannot view the file correctly in Excel. 

 

Is there a way to keep the formatting of the Input Array intact for saving and then for later retrieval? 

 

Thanks,

hiNI

 

2018-09-17_14-48-30.png

0 Kudos
Message 1 of 10
(3,259 Views)

It looks like you're just concatenating all of the strings in your array and writing them to a file without any delimiters, which is going to smush them all together and give you no way to separate them back apart. I'd suggest using this Robust CSV package to create .csv files that can be opened in Excel or re-read in LabVIEW: https://lavag.org/files/file/239-robust-csv/

Message 2 of 10
(3,254 Views)

Hello,

 

I modified the VI as per your suggestion, however, the saved file still seems to be skewed.

 

(see attached VI).

 

Thanks.2018-09-17_16-35-59.png

0 Kudos
Message 3 of 10
(3,231 Views)

In this updated file, the Output Array looks correct, but the saved data is still skewed when opened in Excel.

 

Thanks,

hiNi.

0 Kudos
Message 4 of 10
(3,222 Views)

Your string array has cells in it that have linefeed characters in them.  That is automatically create a new line when you save them.  What do you expect those cells to loo like in the Excel file?

Message 5 of 10
(3,214 Views)

Excel can hold a multi-line string in a single cell. I see that when I export such a cell from Excel to a .csv file, the resulting file has a linefeed character at the end of each line in the string, and Excel opens that file correctly. Can you attach your generated .csv file?

Message 6 of 10
(3,184 Views)

Hello,

 

I have attached is the generated CSV file.  

 

I wanted the Excel file to look like this...

2018-09-18_10-46-26.png

 

Basically, output what the Output Array looks like:

2018-09-18_10-48-57.png

Thanks,

hiNi

0 Kudos
Message 7 of 10
(3,174 Views)

Excel is treating those numbers as strings.  Enclosing the numbers in quotation marks forces Excel (or any other application that correctly interprets a CSV file) to consider the enclosed text as a string of text to be placed in a single cell.  Even if there are line feeds.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 8 of 10
(3,170 Views)

Is there a solution for this issue then?

 

Thanks.

0 Kudos
Message 9 of 10
(3,166 Views)
Solution
Accepted by topic author hiNI

Change the file extension to ".csv" and Excel opens it correctly.

Message 10 of 10
(3,153 Views)