Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle duplicated channels in tdms #164

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions nominal/_tdms.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

def tdms_with_time_column_to_pandas(path: Path, timestamp_column: str) -> pd.DataFrame:
group_dfs: list[pd.DataFrame] = []
channels_to_export: dict[str, pd.Series[Any]] = {}

with TdmsFile.open(path) as tdms_file:
for group, time_channel in _get_groups_with_time_channel(tdms_file.groups(), timestamp_column):
channels_to_export: dict[str, pd.Series[Any]] = {}
for channel in _get_export_channels(group.channels(), time_channel, timestamp_column):
channel_name = _create_channel_name(group, channel)
channels_to_export[channel_name] = pd.Series(data=channel.read_data(), index=time_channel.read_data())
Expand All @@ -27,7 +27,10 @@ def tdms_with_time_column_to_pandas(path: Path, timestamp_column: str) -> pd.Dat

# format for nominal upload
df = functools.reduce(
lambda left, right: pd.merge(left, right, left_index=True, right_index=True, how="outer"), group_dfs
lambda left, right: pd.merge(
left, right, left_index=True, right_index=True, how="outer", suffixes=["_repeated_1", "_repeated_2"]
),
group_dfs,
)
df.index = df.index.set_names(timestamp_column, level=None)
df = df.reset_index()
Expand Down
Loading