pyexcel.save_as

pyexcel.save_as(**keywords)[source]

Save a sheet from a data source to another one

It accepts two sets of keywords. Why two sets? one set is source, the other set is destination. In order to distinguish the two sets, source set will be exactly the same as the ones for pyexcel.get_sheet(); destination set are exactly the same as the ones for pyexcel.Sheet.save_as but require a ‘dest’ prefix.

param file_name:
 a file with supported file extension
param file_content:
 the file content
param file_stream:
 the file stream
param file_type:
 the file type in content
param session:database session
param table:database table
param model:a django model
param adict:a dictionary of one dimensional arrays
param url:a download http url for your excel file
param with_keys:
 load with previous dictionary’s keys, default is True
param records:a list of dictionaries that have the same keys
param array:a two dimensional array, a list of lists
param keywords:additional parameters, see Sheet.__init__()
param sheet_name:
 sheet name. if sheet_name is not given, the default sheet at index 0 is loaded
param dest_file_name:
 another file name. out_file is deprecated though is still accepted.
param dest_file_type:
 this is needed if you want to save to memory
param dest_session:
 the target database session
param dest_table:
 the target destination table
param dest_model:
 the target django model
param dest_mapdict:
 a mapping dictionary, see pyexcel.Sheet.save_to_memory()
param dest_initializer:
 a custom initializer function for table or model
param dest_mapdict:
 nominate headers
param dest_batch_size:
 object creation batch size. it is Django specific
returns:IO stream if saving to memory. None otherwise

if csv file is destination format, python csv fmtparams are accepted

for example: dest_lineterminator will replace default ‘

to the one you specified

source parameters
loading from file file_name, sheet_name, keywords
loading from memory file_type, content, sheet_name, keywords
loading from sql session, table
loading from sql in django model
loading from query sets any query sets(sqlalchemy or django)
loading from dictionary adict, with_keys
loading from records records
loading from array array
loading from an url url
Saving to source parameters
file dest_file_name, dest_sheet_name, keywords with prefix ‘dest’
memory dest_file_type, dest_content, dest_sheet_name, keywords with prefix ‘dest’
sql dest_session, dest_table, dest_initializer, dest_mapdict
django model dest_model, dest_initializer, dest_mapdict, dest_batch_size

In addition, this function use pyexcel.Sheet to render the data which could have performance penalty. In exchange, parameters for pyexcel.Sheet can be passed on, e.g. name_columns_by_row.