How to use the xlsx2csv.OutFileAlreadyExistsException function in xlsx2csv

To help you get started, we’ve selected a few xlsx2csv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dilshod / xlsx2csv / xlsx2csv.py View on Github external
def convert(self, outfile, sheetid=1):
        """outfile - path to file or filehandle"""
        if sheetid > 0:
            self._convert(sheetid, outfile)
        else:
            if isinstance(outfile, str):
                if not os.path.exists(outfile):
                    os.makedirs(outfile)
                elif os.path.isfile(outfile):
                    raise OutFileAlreadyExistsException("File " + str(outfile) + " already exists!")
            for s in self.workbook.sheets:
                sheetname = s['name']
                sheetstate = s['state']

                # filter hidden sheets
                if sheetstate in ('hidden', 'veryHidden') and self.options['exclude_hidden_sheets']:
                    continue

                # filter sheets by include pattern
                include_sheet_pattern = self.options['include_sheet_pattern']
                if type(include_sheet_pattern) == type(""):  # optparser lib fix
                    include_sheet_pattern = [include_sheet_pattern]
                if len(include_sheet_pattern) > 0:
                    include = False
                    for pattern in include_sheet_pattern:
                        include = pattern and len(pattern) > 0 and re.match(pattern, sheetname)

xlsx2csv

xlsx to csv converter

MIT
Latest version published 3 days ago

Package Health Score

82 / 100
Full package analysis

Similar packages