bottom

Text File Reader

User Rating: / 3
PoorBest 

FileGenPane

Purpose

This generation rule reads text from a file and provides content as a sequence of strings. It is possible to split the content of the file using either constant length or a delimiter.

This generator traverses the file designated by its name from its beginning until the end of file. When the end of file is reached, the generator becomes exhausted.

Files are searched on the server using this order:

  1. The Output area of the user's workspace
  2. The Data area of the user's workspace
  3. The Output area of the first shared workspace
  4. The Dara area of the first shared workspace
  5. and so on with all the shared workspaces.

If you want to loop over the file and restart from the beginning when the end of file is reached you can use a Loopback rule in front of the file extraction rule.

Usage

The basic usage of this rule is to retrieve reference data to enforce the realism of generated data. It is often implemented in conjunction with other rules as front end such as Loopback, Sampler, Filter and CSV Extraction to retrieve the appropriate subset data from the traversed files.

For example, consider you have a CSV file for which you want only the second and third columns if the first matches a given regular expression. Then you can use a Filter (configured with the regular expression applied to the first column of extracted records) and a CSV Extraction to provide only the second and third columns on the filtered records.

Configuration

With the Delimiter Type parameter you can configure the rule to tell the generator to split every n characters or as soon as a delimiter string is found in from the file's input stream.

If you specify a delimiter size of -1 with a delimiter type Size, then the whole file content will be loaded in the first iteration of generation.

With the Include Delimiter parameter, and when a string delimiter string is specified (for example \n for newlines) it is possible to tell the generator to keep or throw away those delimiters.

See also...

The File reader is the basic building block for integrating reference data into your generated data. But is is rarely used alone and you will probably need a couple of other generation rule to plug the File Extraction file with such as:

A Loopback to cycle over the input file again and again 

If you want to loop back at the beginning of the file when the end is reached, you can use a Loopback rule as a front end to your file extraction rule.

A Sampler to randomly choose lines in the input file

If you want to extract data at random positions from the underlying file you can use a Sampler rule as a front end to your file extraction rule. To acheived randomness, the increment of the Sampler must be a random integer generator such as the Range generator.

A Shuffle to ensure all input file lines are provided

While using the Sampler will provide randomness it is also possible that some of the input lines from the file will be always skipped. To ensure that all lines are indeed provided and provided in any order, you can rely on a Shuffle generator.

Add comment


Security code
Refresh