用Python读取*.cdpg文件,不知道结构。

huangapple go评论90阅读模式
英文:

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

根据此文档 https://www.ni.com/pl-pl/support/documentation/supplemental/12/logging-data-with-national-instruments-citadel.html

.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

huangapple
  • 本文由 发表于 2023年2月16日 19:12:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/75471422.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定