07-25-2012 05:12 PM
How do I save the data in the portal to a CSV with channel units in the second row of the CSV?
Solved! Go to Solution.
07-25-2012 06:00 PM
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.
07-26-2012 02:57 AM
I assume there is no way to add unit in second line.
Maybe access TDM/TDMS from Matlab may help you.
Greetings
Andreas
07-26-2012 07:52 AM
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.
07-26-2012 09:51 AM - edited 07-26-2012 09:53 AM
Have a look at
http://forums.ni.com/t5/DIAdem/comma-as-decimal-separator/m-p/726321#M8851
I assume Brad saved your day. He attached an example http://forums.ni.com/ni/attachments/ni/60/2115/1/DIAdem%20ASCII%20Export.zip .
07-26-2012 12:56 PM
Not the first time Brad has provided a solution for my needs. 🙂
Thanks!
08-09-2018 10:48 AM
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?
08-10-2018 05:55 PM
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?
09-12-2018 04:24 PM
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
09-12-2018 04:33 PM
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