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

set None value for undefined LoD entries #13

Closed
WolfgangFahl opened this issue Sep 23, 2020 · 0 comments
Closed

set None value for undefined LoD entries #13

WolfgangFahl opened this issue Sep 23, 2020 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@WolfgangFahl
Copy link
Owner

 def setNone4List(self,listOfDicts,fields):
        '''
        set the given fields to None for the records in the given listOfDicts
        if they are not set
        Args:
            listOfDicts(list): the list of records to work on
            fields(list): the list of fields to set to None 
        '''
        for record in listOfDicts:
            self.setNone(record, fields)
    
    def setNone(self,record,fields):
        '''
        make sure the given fields in the given record are set to none
        Args:
            record(dict): the record to work on
            fields(list): the list of fields to set to None 
        '''
        for field in fields:
            if not field in record:
                record[field]=None

but make sure a copy of the records is optionally used to keep the original list of dict as is.

@WolfgangFahl WolfgangFahl added the enhancement New feature or request label Sep 23, 2020
@WolfgangFahl WolfgangFahl added this to the 0.0.17 milestone Sep 23, 2020
@WolfgangFahl WolfgangFahl self-assigned this Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant