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

Allow column_names to be a method in Table.__init__ #724

Closed
jpmckinney opened this issue Jan 2, 2019 · 1 comment
Closed

Allow column_names to be a method in Table.__init__ #724

jpmckinney opened this issue Jan 2, 2019 · 1 comment
Labels

Comments

@jpmckinney
Copy link
Member

jpmckinney commented Jan 2, 2019

If a method is passed as column_names, this method should take the number of columns as an argument, and return column names. For example, if I wanted Excel columns like 'AA,AB,AC' instead of agate columns like 'aa,bb,cc', I would be able to pass it this method:

def excel_column_names(n):
    column_names = []
    for col_idx in range(1, n + 1):
        # From openpyxl's cell.py
        letters = []
        while col_idx > 0:
            col_idx, remainder = divmod(col_idx, 26)
            # check for exact division and borrow if needed
            if remainder == 0:
                remainder = 26
                col_idx -= 1
            letters.append(chr(remainder + 64))
        column_names.append(''.join(reversed(letters)))
    return column_names
@jpmckinney
Copy link
Member Author

I'm abandoning the feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant