Export .d file to csv file with my program

Dear all

For some reasons, I need to read the data archived in “C:\Program Files\openPDC\Archive” folder which saved as .d file. Use the Historian Playback is not a good idea for my project, because I want to make the transfer automatically (rather than selecting start time and end time manually).

According to the openPDC_D_Historical_File_Format.doc

, the format of .d file is special. From the source code of Historian Playback, I found that SaveFileDialog has been used.

My question is, do we need the additional support of GSF to transfer files or can we just use SaveFileDialog to transfer files? (like output a .txt file to .csv)

I am still a beginner to c# and .net so the description may be not accurate. I am quite grateful for any hints you could give.

Best regards
Aaron

Hello Aaron,

The SaveFileDialog provides the interface for the user to select a file from the file system using a dialog window that is similar in function to Windows Explorer. The SaveFileDialog API only returns the path to the file that the user selected. It does not read or modify any files and so cannot by itself be used to convert *.d files to other formats.

What you will need for this task is the ArchiveReader API from the GSF.Historian.dll assembly. For an example of ArchiveReader usage, you can look at the code in the Historian Trending Tool (HistorianView.exe).

Open an ArchiveReader:
https://github.com/GridProtectionAlliance/gsf/blob/master/Source/Tools/HistorianView/MainWindow.xaml.cs#L600

Read metadata records:
https://github.com/GridProtectionAlliance/gsf/blob/master/Source/Tools/HistorianView/MainWindow.xaml.cs#L530

Reading various properties from a metadata record:
https://github.com/GridProtectionAlliance/gsf/blob/master/Source/Tools/HistorianView/MainWindow.xaml.cs#L153

Read data from ArchiveReader:
https://github.com/GridProtectionAlliance/gsf/blob/master/Source/Tools/HistorianView/ChartWindow.xaml.cs#L239

As for your comment about reading data automatically without specifying start and end time, the startTime and endTime parameters are actually optional. However, leaving off those parameters will get you all the data in the archive, not just the data in a single archive file. The API wasn’t really designed to read data from individual files but rather the archive as a whole because it needs to coordinate with the process that is actively writing data to the archive multiple times per second. Note that even historic files may be updated by the writer after a rollover in order to keep data organized and time-sorted.

Thanks,
Stephen

1 Like