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

strip extra space for column name #210

Merged
merged 1 commit into from
Mar 12, 2024
Merged

Conversation

mutantsan
Copy link
Contributor

@mutantsan mutantsan commented Mar 6, 2024

If we have an extra space after truncating the column name, the validation from this function will fail:

def is_valid_field_name(name: str):
    '''
    Check that field name is valid:
    * can't start or end with whitespace characters
    * can't start with underscore
    * can't contain double quote (")
    * can't be empty
    '''
    return (name and name == name.strip() and
            not name.startswith('_') and
            '"' not in name)

I'm adding an extra strip to ensure, that the column name doesn't end with whitespace after truncating.

ThrawnCA added a commit to qld-gov-au/ckanext-xloader that referenced this pull request Mar 8, 2024
- Excel tends to generate files with lots of extra commas at the end of every row.
The header row ignores them, so data rows need to be able to ignore them as well.
- Also strip trailing whitespace from headers after truncating them, in case the truncation exposed some,
see ckan#210
@wardi wardi merged commit 95edb97 into ckan:master Mar 12, 2024
3 checks passed
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.

3 participants