{"id":9987,"library":"nptdms","title":"npTDMS","description":"npTDMS is a cross-platform, NumPy-based Python module designed for reading TDMS files, a binary data format produced by LabVIEW and LabWindows/CVI from National Instruments. It provides efficient access to measurement data and metadata. The current version is 1.10.0, and the library maintains an active development cycle with frequent releases addressing bug fixes, performance improvements, and new features.","status":"active","version":"1.10.0","language":"en","source_language":"en","source_url":"https://github.com/adamreeve/npTDMS","tags":["data-science","measurement","labview","tdms","numpy","data-acquisition"],"install":[{"cmd":"pip install nptdms","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency for data handling and array operations.","package":"numpy","optional":false},{"reason":"Optional dependency for converting TDMS data to Pandas DataFrames.","package":"pandas","optional":true}],"imports":[{"symbol":"TdmsFile","correct":"from nptdms import TdmsFile"}],"quickstart":{"code":"import os\nfrom nptdms import TdmsFile\n\n# Create a dummy .tdms file for demonstration if it doesn't exist\n# In a real scenario, you would have an existing TDMS file.\n# For this quickstart, we'll simulate opening one.\n# Note: nptdms primarily reads existing files; writing requires TdmsWriter.\n\ntdms_file_path = \"example.tdms\"\n# Normally, you'd ensure this file exists. For a runnable example without actual file creation,\n# we'll just demonstrate the read pattern.\n\ntry:\n    # Open the TDMS file\n    with TdmsFile(tdms_file_path) as tdms_file:\n        print(f\"Successfully opened TDMS file: {tdms_file_path}\")\n        \n        # Iterate through all groups and channels\n        print(\"\\nAvailable Groups and Channels:\")\n        for group in tdms_file.groups():\n            print(f\"  Group: {group.name}\")\n            for channel in group.channels():\n                print(f\"    Channel: {channel.name} (Data Type: {channel.dtype})\")\n                # Access data for a channel\n                # data = channel.data # Uncomment to load actual data\n                # print(f\"      Data sample: {data[:5]}...\") # Print first 5 elements\n                \n        # Access a specific group and channel by name (replace with actual names from your file)\n        # try:\n        #     my_group = tdms_file['MyGroupName']\n        #     my_channel = my_group['MyChannelName']\n        #     channel_data = my_channel.data\n        #     print(f\"\\nData from 'MyChannelName': {channel_data[:5]}...\")\n        # except KeyError:\n        #     print(\"\\n'MyGroupName' or 'MyChannelName' not found in the TDMS file.\")\n\nexcept FileNotFoundError:\n    print(f\"Error: The file '{tdms_file_path}' was not found. Please provide a valid TDMS file.\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to open a TDMS file using `TdmsFile` and iterate through its groups and channels to access metadata and data. It includes error handling for `FileNotFoundError` as a common issue. Replace `example.tdms` with the actual path to your TDMS file."},"warnings":[{"fix":"Upgrade your Python environment to version 3.7 or higher.","message":"Support for Python 2.7 and Python 3.6 was dropped in npTDMS v1.6.0. Users on these Python versions must upgrade to Python 3.7 or newer to use v1.6.0+.","severity":"breaking","affected_versions":">=1.6.0"},{"fix":"Upgrade npTDMS to the latest version: `pip install --upgrade nptdms`. Ensure NumPy is also updated: `pip install --upgrade numpy`.","message":"npTDMS v1.10.0 includes critical fixes for compatibility with NumPy 2.x. Older versions of npTDMS (pre-1.10.0) may encounter errors or deprecation warnings when used with newer NumPy installations.","severity":"breaking","affected_versions":"<1.10.0"},{"fix":"Upgrade npTDMS to the latest version (`pip install --upgrade nptdms`) to benefit from enhanced read performance.","message":"Drastic performance improvements for reading TDMS files were introduced in v1.10.0. Users on older versions (especially with large files) might experience significantly slower data loading times.","severity":"gotcha","affected_versions":"<1.10.0"},{"fix":"Upgrade npTDMS to the latest version (`pip install --upgrade nptdms`) to ensure robust handling of various TDMS file structures and prevent data integrity issues.","message":"Older versions of npTDMS (pre-1.9.0) had fixes for reading truncated data and incomplete final segments. Using older versions may lead to misinterpretation or loss of data from malformed TDMS files.","severity":"gotcha","affected_versions":"<1.9.0"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Verify the exact group/channel names within your TDMS file. You can iterate through `tdms_file.groups()` and `group.channels()` to list all available names: `for group in tdms_file.groups(): print(group.name); for channel in group.channels(): print(channel.name)`.","cause":"Attempting to access a non-existent group or channel by name. Group and channel names are case-sensitive and must match exactly.","error":"KeyError: 'My Group Name' (or 'My Channel Name')"},{"fix":"Access groups and channels by their string names, for example, `tdms_file['GroupName']` and `group['ChannelName']`. To iterate, use `tdms_file.groups()` and `group.channels()` methods.","cause":"Trying to access groups or channels using integer indices (e.g., `tdms_file[0]`) instead of their string names.","error":"TypeError: 'TdmsFile' object is not subscriptable"},{"fix":"Upgrade npTDMS to the latest version (`pip install --upgrade nptdms`). Version 1.10.0 specifically addresses compatibility with NumPy 2.0.","cause":"This and similar NumPy deprecation warnings often occur when an older version of npTDMS interacts with a newer version of NumPy, where API behaviors have changed.","error":"numpy.VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated..."}]}