英文:
Reading *.cdpg file with python without knowing structure
问题
我正在尝试使用Python来读取一个.cdpg文件。这个文件是由LabVIEW代码生成的。我无法获取有关文件结构的任何信息。使用另一个帖子,我已经取得了一些成功,但数字没有任何意义。我不知道是我的代码有问题,还是我的数据解释有问题。
我正在使用的代码是:
import struct
with open(file, mode='rb') as file: # b is important -> binary
fileContent = file.read()
ints = struct.unpack("i" * ((len(fileContent) - 24) // 4), fileContent[20:-4])
print(ints)
文件位于这里。非常感谢任何指导。
谢谢,
T
英文:
I am trying to use python to read a .cdpg file. It was generated by the labview code. I do not have access to any information about the structure of the file. Using another post I have had some success, but the numbers are not making any sense. I do not know if my code is wrong or if my interpretation of the data is wrong.
The code I am using is:
import struct
with open(file, mode='rb') as file: # b is important -> binary
fileContent = file.read()
ints = struct.unpack("i" * ((len(fileContent) -24) // 4), fileContent[20:-4])
print(ints)
The file is located here. Any guidance would be greatly appreciated.
Thank you,
T
答案1
得分: 1
.cdpg 文件包含跟踪数据。Citadel以压缩格式存储数据,因此无法直接读取和提取这些文件中的数据。您必须使用DSC模块中的Citadel API或历史数据查看器来访问跟踪数据。有关从Citadel数据库检索数据的更多信息,请参考Citadel操作部分。
.cdpg 是一种包含压缩数据的封闭格式。如果不了解文件格式结构,您将无法正确解释它们。您可以读取原始二进制内容,这正是您的示例Python代码实际在做的事情。
英文:
According to the documentation here https://www.ni.com/pl-pl/support/documentation/supplemental/12/logging-data-with-national-instruments-citadel.html
> The .cdpg files contain trace data. Citadel stores data in a
> compressed format; therefore, you cannot read and extract data from
> these files directly. You must use the Citadel API in the DSC Module
> or the Historical Data Viewer to access trace data. Refer to the
> Citadel Operations section for more information about retrieving data
> from a Citadel database.
.cdpg is a closed format containing compressed data. You won't be able to interpret them properly not knowing the file format structure. You can read the raw binary content and this is what you're actually doing with your example Python code
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论