Read_Text_Columns
Synopsis
Reads an ASCII file containing any number of separated columns, often the result of exporting a spreadsheet.
Input Port
Parameters
if set, column names and types are determined automatically by reading first lines of file
Output Port
Description
The Read_Text_Columns (the Network Editor name is shortened to Rd_Txt_Columns) module reads any ASCII file that contains columns of data separated by a special character or sequence of characters. These type of files often result from exporting a spreadsheet or database into a text format. The columns in the file can be of any type: character strings, integers, or real numbers. Optionally, the file can have a header line that contains the column's names. The module stops reading when it reaches the end of the file.
Here are some simple examples of column-formatted ASCII files. The following file has three columns separated by spaces:
1 bob 180.3
2 jim 230.65
3 bill 201.6The next file contains the same three columns of data, but the columns are separated by (nonprinting) tab characters and the file has a header:
# name weight
1 bob 180.3
2 jim 230.65
3 bill 201.6Column-formatted ASCII files are produced by many software packages; spreadsheets are common examples.
Rd_Txt_Columns provides a number of column parameters that you can use to specify whether and how individual columns in the file are processed. You use the Column Setup menu to specify a column whose parameters you want to set, and then use the following parameters to set processing specifics:
For details, see their descriptions in the Parameters section of this reference page.
Rd_Txt_Columns outputs an array of objects of type Data_Array. You can map the output to the Uniform_Field or Scattered_Field types using the Database Kit modules Table_to_Uniform_Field or Table_to_Scattered_Field. Once mapped to Uniform_Field or Scattered_Field, the data is suitable for visualizing in AVS/Express.
Note: This module may be useful to Database Kit application developers because it allows the use of ASCII files, rather than a database, to provide sample "query output" for testing Database Kit applications. Using an ASCII file instead of establishing a test database with tables, views, and data may therefore simplify testing.
This module was formerly named Read_Column_File.
Input
Parameters
A toggle that causes the module to treat the first line (after skipping the number of lines specified by the skip lines parameter) as a header that contains column names. The default is OFF.
A choice of characters to use as column separators. The allowed values are "space", "tab", ",", ";", ":", and "user". If you select "user", the value specified for the user separator parameter is treated as the column separator.
A toggle that causes the module to look at the first lines of the file to generate column names and types. If the has header line parameter is set, the header is used to generate column names, otherwise the names are "column_0", "column_1", and so forth. The type for each column is determined by examining the line following the header, if one exists.
An integer typein that specifies the number of columns in the file. If the columns_setup_from_file parameter is set, this number is generated automatically, otherwise you must enter it.
A string typein that specifies the name of the column specified by Columns_Setup. If the columns setup from file parameter is set, the column names are generated automatically from the header if one exists, otherwise they are assigned default names. You can overwrite this string with a name of your choice.
Radio box items that specify the type of the output data for the column specified by Columns_Setup. The allowed values are byte, short, int, float, double, and string.
A value that is to be used to represent a null value for the column specified by Columns_Setup if Read_Column_File encounters a missing entry. This parameter is used only for numeric types. For strings, the "" string is substituted for a missing entry.
Output Port
An array of objects of type Data_Array. It can be converted to the Uniform_Field or Scattered_Field types using the table_to_uniform_field and table_to_scattered_field modules.
Example
File
See also related modules