Skip to content

Copy column to clipboard#167

Open
giantatwork wants to merge 7 commits intoYS-L:mainfrom
giantatwork:copy_column
Open

Copy column to clipboard#167
giantatwork wants to merge 7 commits intoYS-L:mainfrom
giantatwork:copy_column

Conversation

@giantatwork
Copy link
Copy Markdown
Contributor

@giantatwork giantatwork commented Dec 3, 2025

Hello @YS-L,

This PR addresses and implements Issue #150, which requested the ability to easily extract column data from the table view. I found this to be a highly valuable feature and decided to implement it.

This PR introduces functionality that allows users to copy the values of an entire selected column to the clipboard.

Key Features and Implementation Details

1. Column Copy-to-Clipboard

This feature is designed for speed and clarity in data extraction:

  • Trigger: When a column is selected (using Tab) to switch to column selection mode), pressing the y key will copy the values of that column to the clipboard.
  • Filtered Data: If a filter is active, only the values from the filtered rows are copied.
  • Unfiltered Data: If no filter is active, all rows in the column are copied.
  • Sort Order: The copied values are extracted in a sequence that respects the current sort order of the table.

2. Clipboard Limit for Performance

To prevent potential performance issues and clipboard overflow when dealing with extremely large datasets, a sensible limit is enforced:

  • Default Limit: The maximum number of rows copied is set to 10,000 by default.
  • Custom Configuration: This limit can be easily adjusted using the new $\texttt{--clipboard-limit}$ command-line argument:
    csvlens data.csv --clipboard-limit 50000

3. User Feedback and Status

After a copy operation, clear and informative feedback is provided to the user:

  • The status message displays the name of the copied column.
  • It indicates the exact number of rows that were successfully copied.
  • If the operation exceeded the limit, the status message explicitly indicates that the output was truncated due to the limit.

I look forward to your review and feedback on this implementation.

Kind regards.

Copy link
Copy Markdown
Owner

@YS-L YS-L left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. A few thoughts:

  • I think this should probably follow the behaviour of 'copy rows', which doesn’t apply filters. (I was wrong, copying rows does apply filters)
  • Even with clipboard_limit, fetching many rows can still stall the UI. This likely needs to run in a background thread.

The changes feel a bit complex for now, and I'm not fully comfortable merging this as is.

Ok(values)
}

pub fn get_column_values_for_indices(
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading a large number of rows this way without using the indexing in CsvLensReader can be slow. It also seems to duplicate quite a bit of the code there.

@giantatwork
Copy link
Copy Markdown
Contributor Author

@YS-L
I totally understand your point of view. The added complexity, and the uncertainty of how it will work out in the wild across different platforms and machines, are valid concerns. Still, it was fun to build this proof of concept. Maybe it can be revived later on?

@YS-L
Copy link
Copy Markdown
Owner

YS-L commented Dec 9, 2025

Yes, revisiting this later could be a good idea. Thanks again for exploring this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants