04-27-2009 08:22 AM
Hello,
I want to import data from an txt-file (see attachement). Well, no proplem, but I want also read the information about the channel names and the units and rename the imported channels. Is it possible to do so? Its also important that the number of channels can vary.
Can anyone give me some example code?
Thanks a lot
Gabriel
Solved! Go to Solution.
05-08-2009 04:15 AM
Hello fischerg,
please find attached a dataplugin which will read your file.
All you need to do is download the file to your machine, unzip it and double click the ".uri" file.
This installs the dataplugin automatically. Once this is done (no reboot required) you can drag&drop the files like any other DIAdem internal file like TDM
If you want to use it to index the files with Datafinder, please make sure DataFinder is configured to use it.
I configured the dataplugin to read the channel names and channel units from the file. If you are interested, take a look at the source code, its pretty short.
The key element is using regular expressions to describe the pattern used for the channel headers. This makes teh remaining code very straightforward.
If you find a file which does not work, please provide the file so that we can check for the problem.
Andreas
05-08-2009 11:21 AM
Hello Andreas,
Thanks for the plugin. But I'm sorry, it doesn't work. I atach the file, maybe you can help me and find out why it doesn't work?
Thanmks
Gabriel
05-11-2009 03:00 AM
Hello fischerg,
Looking at your second file, I immediately saw the problem. I was under the assumption that the channel names always had a certain number of "."'s in the name. I now simplified the pattern for the file name. As a result this is more stable now. I have attached the updated Dataplugin.
It would be possible to split the channel names further, e.g.. to remove elements which are the same for each channel (like "Gabelstapler.Last_Run" which repeats in every channel name). To do so, one need to know whether this is helpful and what assumptions can be made for all of your files.
Andreas
05-11-2009 05:37 AM
Hello Andreas,
Thanks a lot for the new plugin. it works fine.
Yes, I wan't the channel names. The first channel in the file aways will be"A. .Gabelstapler.Last_Run.TIME (sec)" ad should be named as "Time. The follwowing channels in the file have the name like
"B. .Gabelstapler.Last_Run.MEA_Messmarker_Antriebsachse.Q (mm/sec**2)".
The ".Gabelstapler.Last_Run." is always the same (for one simulation). In general, it will be" .[Modelname].Last_Run.", so all the characters between the first 3 dots. The "MEA_" could be usefull, so I will cut the string by my own (Can you tell me the function to use?)
The ".Q" at the end is needless (but only channel 2 to n, the first channel ends with TIME!!)
Is it possible to run a skript automatically in DIAdem after opening an file? I wrote a skript, which eliminates needless data so that the time steps are all equal an creates waveform-channels.
Thanks
Gabriel
05-11-2009 08:05 AM
05-11-2009 12:20 PM
Hello Andreas,
Thanks for your work. I'll adjust the code.
Gabriel