How do I write a DIAdem DataPlugin for Different File Formats That Have the Same Extension?
Primary Software: DIAdem
Primary Software Version: 10.0
Primary Software Fixed Version: N/A
Secondary Software: DIAdem
Problem: I have multiple files that all have the same extension such as .csv, but the files all have a different internal structure. How can I access the information in these files through DIAdem DataPlugins?
Solution: There are a number of different approaches to this problem. The best solution depends on personal preferences and the information available in the data files, as well as the number of files and if they may be edited. All of the solutions require modifying the DataPlugin to recognise the source of the file.
- The DataPlugin can be written so that it looks in the header of the file and evaluates which location the data came from and then execute a sub-routine based on the origin of the file. This solution does not require any modification to the file, but does require unique information contained in the file that DIAdem can read.
- Multiple DataPlugins can be written that each handle just one source of data. The DataPlugins would need to evaluate the origin of the file possibly through the header, and if the source was not the one desired, then the plugin can be written to throw an error. In DIAdem if a DataPlugin throws an error for a given file type, it will automatically try the next data-plugin for that file type. Using this method DIAdem will keep trying DataPlugins until it finds one that does not throw an error based on your conditions. Like the first option this solution does not require any modification to the file, but does require the file contain unique information in the file that DIAdem can parse. This option would require fewer DataPlugins, but may result in more complex code.
- The file names themelves can be changed to add an additional key phrase. So myData.csv could be changed to myData.teststation1.csv. This naming convention will allow any outside programs to read the file as a .csv but once the DataPlugin reads in the file, It can be written to evaluate the name of the file, and pull out the expression "teststation1". Once this information is extracted it can then execute a subroutine based on the value it returns. This option does not require any header or unique information in the file itself, but if not already named in this fashion, renaming a large quantity of files by hand can be time consuming.
- With DIAdem 11.1 (DataFinder Server Edition 2.1) you can call RaiseError without any parameters. This will let DIAdem know that this file is not the correct type for a specific DataPlugin. Doing this will cause a ? icon in DataFinder and will not return an index failure.
Related Links: KnowledgeBase 4Y9GBAW8: How Do I Edit a URI file in DIAdemKnowledgeBase 4W9CI76X: How do I Uninstall or Remove a Registered DataPlugin?Developer Zone Tutorial: Installing a DataPlugin
Attachments:
Report Date: 06/17/2009
Last Updated: 07/13/2009
Document ID: 4YGG4OW8