/// <summary> /// Read a data view from a text file using <see cref="TextLoader"/>. /// </summary> /// <param name="catalog">The catalog.</param> /// <param name="columns">The columns of the schema.</param> /// <param name="advancedSettings">The delegate to set additional settings</param> /// <param name="path">The path to the file</param> /// <returns>The data view.</returns> public static IDataView ReadFromTextFile(this DataOperations catalog, TextLoader.Column[] columns, string path, Action <TextLoader.Arguments> advancedSettings = null) { Contracts.CheckNonEmpty(path, nameof(path)); var env = catalog.GetEnvironment(); // REVIEW: it is almost always a mistake to have a 'trainable' text loader here. // Therefore, we are going to disallow data sample. var reader = new TextLoader(env, columns, advancedSettings, dataSample: null); return(reader.Read(new MultiFileSource(path))); }
/// <summary> /// Read a data view from a text file using <see cref="TextLoader"/>. /// </summary> /// <param name="catalog">The catalog.</param> /// <param name="columns">The columns of the schema.</param> /// <param name="hasHeader">Whether the file has a header.</param> /// <param name="separatorChar">The character used as separator between data points in a row. By default the tab character is used as separator.</param> /// <param name="path">The path to the file.</param> /// <returns>The data view.</returns> public static IDataView ReadFromTextFile(this DataOperations catalog, string path, Column[] columns, bool hasHeader = false, char separatorChar = '\t') { Contracts.CheckNonEmpty(path, nameof(path)); var env = catalog.GetEnvironment(); // REVIEW: it is almost always a mistake to have a 'trainable' text loader here. // Therefore, we are going to disallow data sample. var reader = new TextLoader(env, columns, hasHeader, separatorChar, dataSample: null); return(reader.Read(new MultiFileSource(path))); }