@@ -80,6 +80,20 @@ def get_array(self, **keywords):
80
80
params = self .get_params (** keywords )
81
81
return pe .get_array (** params )
82
82
83
+ def iget_array (self , ** keywords ):
84
+ """
85
+ Get a generator for a list of lists from the file
86
+
87
+ :param sheet_name: For an excel book, there could be multiple
88
+ sheets. If it is left unspecified, the
89
+ sheet at index 0 is loaded. For 'csv',
90
+ 'tsv' file, *sheet_name* should be None anyway.
91
+ :param keywords: additional key words
92
+ :returns: A generator for a list of lists
93
+ """
94
+ params = self .get_params (** keywords )
95
+ return pe .iget_array (** params )
96
+
83
97
def get_dict (self , ** keywords ):
84
98
"""Get a dictionary from the file
85
99
@@ -110,6 +124,19 @@ def get_records(self, **keywords):
110
124
params ['name_columns_by_row' ] = 0
111
125
return pe .get_records (** params )
112
126
127
+ def iget_records (self , ** keywords ):
128
+ """Get a generator of a list of records from the file
129
+
130
+ :param sheet_name: For an excel book, there could be multiple
131
+ sheets. If it is left unspecified, the
132
+ sheet at index 0 is loaded. For 'csv',
133
+ 'tsv' file, *sheet_name* should be None anyway.
134
+ :param keywords: additional key words
135
+ :returns: A generator of alist of records
136
+ """
137
+ params = self .get_params (** keywords )
138
+ return pe .iget_records (** params )
139
+
113
140
def save_to_database (self , session = None , table = None ,
114
141
initializer = None , mapdict = None ,
115
142
auto_commit = True ,
@@ -138,6 +165,34 @@ def save_to_database(self, session=None, table=None,
138
165
params ['dest_auto_commit' ] = auto_commit
139
166
pe .save_as (** params )
140
167
168
+ def isave_to_database (self , session = None , table = None ,
169
+ initializer = None , mapdict = None ,
170
+ auto_commit = True ,
171
+ ** keywords ):
172
+ """
173
+ Save data from a sheet to database
174
+
175
+ :param session: a SQLAlchemy session
176
+ :param table: a database table
177
+ :param initializer: a custom table initialization function if
178
+ you have one
179
+ :param mapdict: the explicit table column names if your excel
180
+ data do not have the exact column names
181
+ :param keywords: additional keywords to
182
+ :meth:`pyexcel.Sheet.save_to_database`
183
+ """
184
+ params = self .get_params (** keywords )
185
+ if 'name_columns_by_row' not in params :
186
+ params ['name_columns_by_row' ] = 0
187
+ if 'name_rows_by_column' not in params :
188
+ params ['name_rows_by_column' ] = - 1
189
+ params ['dest_session' ] = session
190
+ params ['dest_table' ] = table
191
+ params ['dest_initializer' ] = initializer
192
+ params ['dest_mapdict' ] = mapdict
193
+ params ['dest_auto_commit' ] = auto_commit
194
+ pe .isave_as (** params )
195
+
141
196
def get_book (self , ** keywords ):
142
197
"""Get a instance of :class:`Book` from the file
143
198
@@ -181,6 +236,31 @@ def save_book_to_database(self, session=None, tables=None,
181
236
params ['dest_auto_commit' ] = auto_commit
182
237
pe .save_book_as (** params )
183
238
239
+ def isave_book_to_database (self , session = None , tables = None ,
240
+ initializers = None , mapdicts = None ,
241
+ auto_commit = True , ** keywords ):
242
+ """
243
+ Save a big book into database
244
+
245
+ :param session: a SQLAlchemy session
246
+ :param tables: a list of database tables
247
+ :param initializers: a list of model
248
+ initialization functions.
249
+ :param mapdicts: a list of explicit table column names
250
+ if your excel data sheets do not have
251
+ the exact column names
252
+ :param keywords: additional keywords to
253
+ :meth:`pyexcel.Book.save_to_database`
254
+
255
+ """
256
+ params = self .get_params (** keywords )
257
+ params ['dest_session' ] = session
258
+ params ['dest_tables' ] = tables
259
+ params ['dest_initializers' ] = initializers
260
+ params ['dest_mapdicts' ] = mapdicts
261
+ params ['dest_auto_commit' ] = auto_commit
262
+ pe .isave_book_as (** params )
263
+
184
264
185
265
class ExcelInputInMultiDict (ExcelInput ):
186
266
"""
0 commit comments