DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

CSV Export with Units

Solved!
Go to solution

How do I save the data in the portal to a CSV with channel units in the second row of the CSV? 

0 Kudos
Message 1 of 15
(6,512 Views)

Perhaps I should clarify a little.  I am using diadem as a bridge between a custom MATLAB analysis tool and a AOP data store.  I need to save the file as a tab-delimited text file with an extension of .xls.  Using File->Save As with text file-Auto Detect, works as expected, except that I don't get the units of the data channels.  I have tried to use excel export to save it as an xls, but my custom MATLAB tool does not like the file. 

 

In case someone is going to suggest it, I have attempted to save my data as a *.mat file so MATLAB can open it's own format, but I get some odd behavior with the MATLAB variable names.  I am investigating how to correct this, but in the mean time, I need a bridge to save the file as a tab-delimited text file. 

 

Thanks. 

0 Kudos
Message 2 of 15
(6,509 Views)

I assume there is no way to add unit in second line.

Maybe access TDM/TDMS from Matlab may help you.

 

Greetings

Andreas

0 Kudos
Message 3 of 15
(6,502 Views)

That's unfortunate... Diadem can read in units from a text file, but not write them?  I believe I could do this programatically with txt file write commands, but I feel like I would be re-inventing the wheel. 

 

Thanks for the link, I will read about getting MATLAB to open a TDM(S) file, but at that point, I think getting Diadem to export directly to a .mat file would probably be easier for me. 

0 Kudos
Message 4 of 15
(6,494 Views)
Solution
Accepted by topic author RSenior
0 Kudos
Message 5 of 15
(6,487 Views)

Not the first time Brad has provided a solution for my needs.  🙂  

 

Thanks! 

0 Kudos
Message 6 of 15
(6,477 Views)

I tried this method and it sort of worked, but not really.  I got the units to export to the text file as a line of tab delimited strings below the channel names, but many units came out incorrect.  For example "m/s" becomes "m\s".  Is this due to a character limitation in DIAdem channel names or am I missing something?

0 Kudos
Message 7 of 15
(4,072 Views)

Hi Chris_P_SD,

 

I'm not sure exactly why the ASCII characters are switched, but my guess is that since "/" is a valid separator in DIAdem, DIAdem is altering this value intentionally.

 

Is this causing a large problem for you? If so, can you elaborate?

Andy F.
Applications Engineering
National Instruments
0 Kudos
Message 8 of 15
(4,058 Views)

Hi Chris,

 

The "/" got switched to "\" because my posted script temporarily smuggles the unit string as an appended suffix to the last channel name (with a vbCRLF between), thus creating a new unit string row.  DIAdem is policing the channel names and converting the "/" characters to "\" characters because of the "Group/Channel" referencing syntax.

 

DIAdem 2017 shipped with a new "Textfile - Export (*.csv)" option for saving data, which I believe natively supports outputting property rows (of your choosing).  Give that a try and see if it helps.  I wrote the smuggling script before this was an option.  If your file is small to medium, then outputting everything with the VBScript FileSystemObject is an option, but that runs interpreted, so it can be slow for large data sets.

 

As a final Hail Mary, you can create a header file with the FileSystemObject, the channel values with the old DIAdem DAT export (which can create the data values with no name row), then DOS Copy the two files together programmatically.  That's ugly code but it will execute quickly.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 9 of 15
(3,937 Views)

Brad/Andy,

Thanks for your help with this.  I did end up using the VBScript file system object to just scan the units line and replace all the "\" wtih "/".  The files I'm doing this to are all less than 200 MB, so it works plenty fast.

 

VBScript really is quick and easy for stuff like this.

 

Thanks,

Chris

0 Kudos
Message 10 of 15
(3,932 Views)