pyexcel.iget_book¶
-
pyexcel.
iget_book
(**keywords)[source]¶ Get an instance of
BookStream
from an excel sourceFirst use case is to get all sheet names without extracting the sheets into memory.
Here is a table of parameters:
source parameters loading from file file_name, keywords loading from string file_content, file_type, keywords loading from stream file_stream, file_type, keywords loading from sql session, tables loading from django models models loading from dictionary bookdict loading from an url url Where the dictionary should have text as keys and two dimensional array as values.
Parameters
- file_name :
- a file with supported file extension
- file_content :
- the file content
- file_stream :
- the file stream
- file_type :
- the file type in file_content or file_stream
- session :
- database session
- tables :
- a list of database table
- models :
- a list of django models
- bookdict :
- a dictionary of two dimensional arrays
- url :
- a download http url for your excel file
- sheets:
- a list of mixed sheet names and sheet indices to be read. This is done to keep Pandas compactibility. With this parameter, more than one sheet can be read and you have the control to read the sheets of your interest instead of all available sheets.
- auto_detect_float :
- defaults to True
- auto_detect_int :
- defaults to True
- auto_detect_datetime :
- defaults to True
- ignore_infinity :
- defaults to True
- library :
- choose a specific pyexcel-io plugin for reading
- source_library :
- choose a specific data source plugin for reading
- parser_library :
- choose a pyexcel parser plugin for reading
- skip_hidden_sheets:
- default is True. Please toggle it to read hidden sheets
Parameters related to csv file format
for csv, fmtparams are accepted
- delimiter :
- field separator
- lineterminator :
- line terminator
- encoding:
- csv specific. Specify the file encoding the csv file. For example: encoding=’latin1’. Especially, encoding=’utf-8-sig’ would add utf 8 bom header if used in renderer, or would parse a csv with utf brom header used in parser.
- escapechar :
- A one-character string used by the writer to escape the delimiter if quoting is set to QUOTE_NONE and the quotechar if doublequote is False.
- quotechar :
- A one-character string used to quote fields containing special characters, such as the delimiter or quotechar, or which contain new-line characters. It defaults to ‘”’
- quoting :
- Controls when quotes should be generated by the writer and recognised by the reader. It can take on any of the QUOTE_* constants (see section Module Contents) and defaults to QUOTE_MINIMAL.
- skipinitialspace :
- When True, whitespace immediately following the delimiter is ignored. The default is False.
- pep_0515_off :
- When True in python version 3.6, PEP-0515 is turned on. The default is False
When you use this function to work on physical files, this function will leave its file handle open. When you finish the operation on its data, you need to call
pyexcel.free_resources()
to close file hande(s).for csv, csvz file formats, file handles will be left open. for xls, ods file formats, the file is read all into memory and is close afterwards. for xlsx, file handles will be left open in python 2.7 - 3.5 by pyexcel-xlsx(openpyxl). In other words, pyexcel-xls, pyexcel-ods, pyexcel-ods3 won’t leak file handles.