Wiki

Scale Your Enterprise

User Tools

Site Tools


bw:file_reader_tool

This is an old revision of the document!


Introduction

This document describes the use of the “File Reader” tool in Bizweaver. Information regarding the associated File Operations and File Writer tools is found in separate documents.

Audience

This document is intended for developers of Bizweaver workflows.

Related Documents

The following documents contain additional information that may be helpful with the development of Bizweaver workflows.

General Workflow Step Information

  1. Each workflow step must have a unique Name.
    1. The application will assign a default name, but we recommend that you change the name to something that helps you understand the purpose of the step as it is used in other steps.
    2. The name cannot have spaces or special characters other than and underscore (_)
  2. Enter an optional Description to provide any additional information that may be helpful to understanding the step.
  3. Press <F4> to find and use values from previous workflow steps.

Special Note

Beginning in Bizweaver v2.0.170, two File Reader tools are displayed: FileReader and FileReader2. The functions are the same in both tools except for changes for handling XML and JSON files found in FileReader2. While workflows created using FileReader will continue to function, any new workflows should use FileReader2. All references to “FileReader” in this section refer to FileReader2.

The File Reader tool is used to read data from “flat” delimited files and “structured” formats such as XML, JSON, and Microsoft Excel. There is also a special input type called “text reader.” Data read from the file is then available in subsequent processing steps.

The File Reader tool is also used to process data being received from a webservice call. More information on this process can be found in the “Bizweaver – Webservice Tool” document.

File delimiters include:

  • Comma
  • Tab
  • Pipe ( | )
  • User defined

“Structured” file formats include:

  • XML
  • Json
  • Microsoft Excel

General Rules for Using the File Reader Tool

  1. A File Handler step using the “Get” option should be used as input to the File Reader if more than one file may potentially be processed.
  2. The File Reader process uses a “template” file to describe the structure of the source file.
    1. It is recommended that the template file be placed in a separate folder and be named uniquely so that it does not accidently get removed during normal processing.
    2. For files with a header row the template file should have the header row and one or two lines of data.
    3. For files without a header row the template file needs to only have one or two lines of data.

Delimited Files

Example showing static file name.

Example showing input from Get File operation

  1. Select the delimiter type from the drop-down list.
    1. If the “Custom Separated” delimiter option is selected, an additional field is displayed below the Input/File field. Enter the delimiter character here.
  2. The File Reader option requires either a specific source file path & name or a Bizweaver variable that identifies the source file.
    1. A specific file is a reasonable option if the source file name is always the same.
    2. If the source file name may not always be the same, then the Get Files tool should be used as a feed into a looping cycle where the FileReader tool is a step within the loop.
    3. Wildcard file designations are not permitted for the file reader. Use the Get Files tool (File Operations) to process multiple files.
    4. See Appendix A - File Operations Variables for definitions of the options available using step variables.
  3. The File Reader requires the use of a “template” file. This is simply an abbreviated version of the file to be processed. The template is used to define the expected columns when reading an input file.
    1. Best practice is to place the template files in their own folder so they are not mixed with files to be processed.
    2. The column structure and sample data from the template file are displayed in the area below the template file name.
  4. Select the No header row option if the source files do not have a header row.
    1. Use of a header row is not required. However, all files to be processed through this File Reader step must be consistent; header or no header.
  5. Files with, and without header rows are supported (this does not apply to XML and JSON files). There are some basic rules about the column headers.
    1. The name cannot have spaces and should typically not have special characters other than an underscore ( _ ).
    2. The name should be relatively short but should be descriptive enough so that its purpose is apparent.

XML & JSON Files

XML (eXtensible Markup Language) and JSON (JavaScript Object Notation) are structured formats commonly used with websites.

The setup for these formats is the same as described for delimited files, with one exception. When either of these formats is the source, the tool has additional functionality to deal with the hierarchy structures often found in these files. The tool “flattens” the data so that it can be used is subsequent processing.

The sample used for explanation of handling these types of structures is JSON input returned from a web service call. The data being processed is freight carrier information.

The “Use Null Value” option is used in cases where some records in the input file do not have any data. In these cases, the columns can become “mismatched,” causing problems correctly reading the data. The ”null value” option accounts for these missing values based on the template.

When the input is XML or JSON, a new link named “Select object for formatting the data” is displayed. Click on this link to open a new dialog.

This dialog presents the various data groupings (nodes) in the input structure. Select a combination of checkboxes to “flatten” the data to the selected level.

To get the desired results, you must select all the associated higher-level nodes as well. In the first example we want just “RateResults”, so the /root level must be selected as well as /root/RateResults. When this is done we get the following results:

If we now want to get the “Charges” data, we change the object select to look like this:

Note that we must include /root and /root/RateResults as well, since “Charges” is a sub-group of /root/RateResults.

With this change we now see:

If the input structure is complex, you may need to use multiple FileReader steps (with a common input) to get all the data elements you need.

Excel Files

Effective with v91.1.0.161, Bizweaver can process native Microsoft Excel (.xlsx) files. The only limitation is that only the first worksheet in a workbook is processed. The processing of multiple sheets in a workbook is not supported.

The setup for Excel files is the same as described for delimited files.

The Excel file reader requires that the Microsoft Access Database Runtime engine be installed on the Bizweaver server. Contact Third Wave support to obtain the installation package for this application.

Text String Files

The Text Reader option is used when the input file needs to be read as a single string of text. The uses for this option are very specialized and limited.

The only input for this function is a file name, or workflow variable that identifies the file.

Appendix A - File Operations Variables

There are several variables from the File Operations function that can be used in other workflow steps. In the following examples the file being addressed is named “FileName.txt” and it is found in the folder “C:\SourceFolder”.

Variable Name Explanation Example
File Name Full file name including path (folder) C:\SourceFolder\FileName.txt
File Title The file name including the extension FileName.txt
File Title without ExtThe file name without the extension FileName
File Extension The file extension including the “.” separator.txt
File Type File type such as TAB, csv, etc.
Source Path Path of the source file C:\SourceFolder
Source File Name “File” name as defined in a Get Files action Example: “*FileName.txt”
Target Path Path name from a File Writer operation C:\TargetFolder
Target File Name “File” name as defined in a File Writer action Example: “*FileName.txt”
bw/file_reader_tool.1551976818.txt.gz · Last modified: 2019/03/07 11:40 by runger