@@ -119,6 +119,19 @@ public static TextLoader CreateTextLoader<TInput>(this DataOperationsCatalog cat
119
119
=> TextLoader . CreateTextLoader < TInput > ( CatalogUtils . GetEnvironment ( catalog ) , hasHeader , separatorChar , allowQuoting ,
120
120
allowSparse , trimWhitespace , dataSample : dataSample ) ;
121
121
122
+ /// <summary>
123
+ /// Create a text loader <see cref="TextLoader"/> by inferencing the dataset schema from a data model type.
124
+ /// </summary>
125
+ /// <param name="catalog">The <see cref="DataOperationsCatalog"/> catalog.</param>
126
+ /// <param name="options">Defines the settings of the load operation. Defines the settings of the load operation. No need to specify a Columns field,
127
+ /// as columns will be infered by this method.</param>
128
+ /// <param name="dataSample">The optional location of a data sample. The sample can be used to infer information
129
+ /// about the columns, such as slot names.</param>
130
+ public static TextLoader CreateTextLoader < TInput > ( this DataOperationsCatalog catalog ,
131
+ TextLoader . Options options ,
132
+ IMultiStreamSource dataSample = null )
133
+ => TextLoader . CreateTextLoader < TInput > ( CatalogUtils . GetEnvironment ( catalog ) , options , dataSample ) ;
134
+
122
135
/// <summary>
123
136
/// Load a <see cref="IDataView"/> from a text file using <see cref="TextLoader"/>.
124
137
/// Note that <see cref="IDataView"/>'s are lazy, so no actual loading happens here, just schema validation.
@@ -172,6 +185,35 @@ public static IDataView LoadFromTextFile(this DataOperationsCatalog catalog,
172
185
return loader . Load ( new MultiFileSource ( path ) ) ;
173
186
}
174
187
188
+ /// <summary>
189
+ /// Load a <see cref="IDataView"/> from a text file using <see cref="TextLoader"/>.
190
+ /// Note that <see cref="IDataView"/>'s are lazy, so no actual loading happens here, just schema validation.
191
+ /// </summary>
192
+ /// <param name="catalog">The <see cref="DataOperationsCatalog"/> catalog.</param>
193
+ /// <param name="path">Specifies a file from which to load.</param>
194
+ /// <param name="options">Defines the settings of the load operation.</param>
195
+ /// <example>
196
+ /// <format type="text/markdown">
197
+ /// <]
199
+ /// ]]>
200
+ /// </format>
201
+ /// </example>
202
+ public static IDataView LoadFromTextFile ( this DataOperationsCatalog catalog , string path ,
203
+ TextLoader . Options options = null )
204
+ {
205
+ Contracts . CheckNonEmpty ( path , nameof ( path ) ) ;
206
+ if ( ! File . Exists ( path ) )
207
+ {
208
+ throw Contracts . ExceptParam ( nameof ( path ) , "File does not exist at path: {0}" , path ) ;
209
+ }
210
+
211
+ var env = catalog . GetEnvironment ( ) ;
212
+ var source = new MultiFileSource ( path ) ;
213
+
214
+ return new TextLoader ( env , options , dataSample : source ) . Load ( source ) ;
215
+ }
216
+
175
217
/// <summary>
176
218
/// Load a <see cref="IDataView"/> from a text file using <see cref="TextLoader"/>.
177
219
/// Note that <see cref="IDataView"/>'s are lazy, so no actual loading happens here, just schema validation.
@@ -221,27 +263,20 @@ public static IDataView LoadFromTextFile<TInput>(this DataOperationsCatalog cata
221
263
/// </summary>
222
264
/// <param name="catalog">The <see cref="DataOperationsCatalog"/> catalog.</param>
223
265
/// <param name="path">Specifies a file from which to load.</param>
224
- /// <param name="options">Defines the settings of the load operation.</param>
225
- /// <example>
226
- /// <format type="text/markdown">
227
- /// <]
229
- /// ]]>
230
- /// </format>
231
- /// </example>
232
- public static IDataView LoadFromTextFile ( this DataOperationsCatalog catalog , string path ,
233
- TextLoader . Options options = null )
266
+ /// <param name="options">Defines the settings of the load operation. No need to specify a Columns field,
267
+ /// as columns will be infered by this method.</param>
268
+ /// <returns>The data view.</returns>
269
+ public static IDataView LoadFromTextFile < TInput > ( this DataOperationsCatalog catalog , string path ,
270
+ TextLoader . Options options )
234
271
{
235
272
Contracts . CheckNonEmpty ( path , nameof ( path ) ) ;
236
273
if ( ! File . Exists ( path ) )
237
274
{
238
275
throw Contracts . ExceptParam ( nameof ( path ) , "File does not exist at path: {0}" , path ) ;
239
276
}
240
277
241
- var env = catalog . GetEnvironment ( ) ;
242
- var source = new MultiFileSource ( path ) ;
243
-
244
- return new TextLoader ( env , options , dataSample : source ) . Load ( source ) ;
278
+ return TextLoader . CreateTextLoader < TInput > ( CatalogUtils . GetEnvironment ( catalog ) , options )
279
+ . Load ( new MultiFileSource ( path ) ) ;
245
280
}
246
281
247
282
/// <summary>
0 commit comments