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

Add :sep option as alias for :col_sep and TSV class for tab-separated values #317

Closed
wants to merge 1 commit into from

Conversation

jsxs0
Copy link
Contributor

@jsxs0 jsxs0 commented Oct 28, 2024

This PR adds two features to improve the usability of the CSV library:

  1. Adds :sep as an alias for :col_sep

    • Provides a shorter option name (3 vs. 8 keystrokes)
    • Aligns with similar libraries like pandas (pd.read_csv(sep="\t"))
    • Maintains backward compatibility
    • Raises clear error if both options specified
  2. Adds TSV class to handle tab-separated files

    • Inherits from CSV class
    • Uses tab as default separator
    • Full interface parity with CSV
    • All class methods supported (parse, read, generate, etc.)
    • Allows override of default separator if needed

Example usage:

# Using new :sep option
CSV.read("data.tsv", sep: "\t")

# Using new TSV class with default tab separator
TSV.read("data.tsv")
TSV.parse("a\tb\tc")

Inspired by #272

@kou
Copy link
Member

kou commented Oct 28, 2024

Could you use separated PRs for multiple features?

@kou kou closed this Oct 28, 2024
@jsxs0
Copy link
Contributor Author

jsxs0 commented Oct 28, 2024

Continued at #318, #319

@jsxs0 jsxs0 deleted the add-sep-alias-and-tsv-support branch October 28, 2024 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants