Method ImportTextFromFileAsync
ImportTextFromFileAsync(string, Encoding, TextChunking, string, string, CancellationToken)
Asynchronously imports text data from a file into a specified DataSource object, creating or updating a Section entry.
public Task<DataSource> ImportTextFromFileAsync(string path, Encoding encoding, TextChunking textChunking, string dataSourceIdentifier, string sectionIdentifier = "default", CancellationToken cancellationToken = default)
Parameters
path
stringThe file path from which to read the text data.
encoding
EncodingThe character encoding used in the file.
textChunking
TextChunkingA TextChunking object specifying the text chunking strategy to be used.
dataSourceIdentifier
stringThe unique identifier for the DataSource. If this identifier matches an existing DataSource, the data is added to a new section within it. If no matching identifier is found, a new DataSource is created.
sectionIdentifier
stringOptional. The identifier for the new Section. Defaults to 'default'.
cancellationToken
CancellationTokenOptional. A CancellationToken for canceling the operation.
Returns
- Task<DataSource>
A task that represents the asynchronous operation. The task result contains the DataSource object into which the data has been imported.
Exceptions
- ArgumentNullException
Thrown if
path
ordataSourceIdentifier
is null or empty.- OperationCanceledException
Thrown if the operation is canceled.