Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sheetid = options.sheetid
if options.all:
sheetid = 0
outfile = options.outfile or sys.stdout
try:
if os.path.isdir(options.infile):
convert_recursive(options.infile, sheetid, outfile, kwargs)
else:
xlsx2csv = Xlsx2csv(options.infile, **kwargs)
if options.sheetname:
sheetid = xlsx2csv.getSheetIdByName(options.sheetname)
if not sheetid:
raise XlsxException("Sheet '%s' not found" % options.sheetname)
xlsx2csv.convert(outfile, sheetid)
except XlsxException:
_, e, _ = sys.exc_info()
sys.stderr.write(str(e) + "\n")
sys.exit(1)
'workbook',
'worksheet',
'relationships',
}
DEFAULT_APP_PATH = "/xl"
DEFAULT_WORKBOOK_PATH = DEFAULT_APP_PATH + "/workbook.xml"
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
class XlsxException(Exception):
pass
class InvalidXlsxFileException(XlsxException):
pass
class SheetNotFoundException(XlsxException):
pass
class OutFileAlreadyExistsException(XlsxException):
pass
class Xlsx2csv:
"""
Usage: Xlsx2csv("test.xslx", **params).convert("test.csv", sheetid=1)
Input:
xlsxfile - path to file or filehandle
DEFAULT_APP_PATH = "/xl"
DEFAULT_WORKBOOK_PATH = DEFAULT_APP_PATH + "/workbook.xml"
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
class XlsxException(Exception):
pass
class InvalidXlsxFileException(XlsxException):
pass
class SheetNotFoundException(XlsxException):
pass
class OutFileAlreadyExistsException(XlsxException):
pass
class Xlsx2csv:
"""
Usage: Xlsx2csv("test.xslx", **params).convert("test.csv", sheetid=1)
Input:
xlsxfile - path to file or filehandle
options:
sheetid - sheet no to convert (0 for all sheets)
dateformat - override date/time format
timeformat - override time format
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
class XlsxException(Exception):
pass
class InvalidXlsxFileException(XlsxException):
pass
class SheetNotFoundException(XlsxException):
pass
class OutFileAlreadyExistsException(XlsxException):
pass
class Xlsx2csv:
"""
Usage: Xlsx2csv("test.xslx", **params).convert("test.csv", sheetid=1)
Input:
xlsxfile - path to file or filehandle
options:
sheetid - sheet no to convert (0 for all sheets)
dateformat - override date/time format
timeformat - override time format
floatformat - override float format
quoting - if and how to quote
delimiter - csv columns delimiter symbol
sheetdelimiter - sheets delimiter used when processing all sheets