'How to read all DICOM attributes/tags with pydicom?

I'm trying to get a list of all the attributes (tags) of a given DICOM instance using pydicom.

The list should include the attribute key/id, its vr, the value, and also the corresponding name.

For example:

Tag: (2,0)
VR: UL
Name: File Meta Information Group Length
Value: 246

I'd like to get some guidance on how to obtain this information since I can't find anything useful in the pydicom docs.

My code is the following:

import pydicom
from io import BytesIO

dicom_data = await client.download_dicom_file(image_id)
data = pydicom.dcmread(BytesIO(dicom_data))


Solution 1:[1]

Use to_json()
https://pydicom.github.io/pydicom/stable/tutorials/dicom_json.html

Please note that for tags with group num 0x0002, pydicom cannot read them using to_json() and MrBean Bremen's for-loop methods. I am sorry that I have no solution for this limitation.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gino Mempin