Houdini 20.0 Nodes TOP nodes

CSV Input TOP node

Copies data from a CSV file into work item attributes.

On this page
Since 17.5

Overview

This node will create a work item for each row in the input CSV file (but see the Limit rows parameter). It will extract data from certain columns you specify into attributes on the work items, or all columns automatically.

This can be useful to allow users to specify a list of work to do.

The opposite of this node (write attributes on work items into a CSV file) is the CSV Output node.

How to

By default, if this node has input files, it creates a work item for each incoming row, but it does not extract any data. You need to decide how to provide it with CSV data, and specify which columns to extract.

  1. Specify where to get the CSV data. Do one of the following:

    • If you the input work items have CSV files in their result data, select Upstream Output Files.

      For example, if you get a list of files using a File Pattern node, you should add a Wait for All after the file pattern, and then wire the Wait for All into this node. Assuming the File Pattern node only matches *.csv files, set it to tag its output files as file/csv. Finally, on the CSV Input node, select Upstream Output Files.

    • If you want to statically read in one CSV file, select Custom File Path and set the File Path to the path of the static CSV file.

  2. Choose what to extract. Do one of the following:

    • If you want to extract data from individual columns, use the Columns to Extract multiparm to specify the columns to extract and the attribute names to use. If your CSV file has a header row, turn on Has Header Row to tell the node to ignore it instead of using it as data.

    • If you want to extract all columns, turn on Extract all. If your CSV file has a header row, turn on Has Header Row to tell the node to use the header row to name the attributes. If the CSV file has no header, the node will make up attribute names like column_0, column_1, and so on.

    Using Extract all extracts all values as strings. If you want to properly type numbers in the CSV file, you must extract columns manually instead.

  3. You can try generating the items in the node and check their attributes.

Notes

  • If there are multiple input files (from upstream item result paths), this node creates separate work items for each row of each file (however set Limit Rows).

  • To ensure you can cook the network on a render farm, make sure the input CSV files are in the shared network filesystem.

TOP Attributes

csv_rowindex

integer

The index of the row in the CSV file that the work item is created from. This is 0-based, and does not include the header row if there is one.

csv_columns

string array

An array of the names of attributes that were extracted from the CSV row. This attribute is optionally created, and can be used by CSV Output node.

Parameters

Input

CSV Source

Where CSV file is read from.

Custom File Path

Specify the path of a single CSV file to load from (this field does not support file patterns).

Upstream Output Files

Use the output file paths of the incoming work items as the file(s) to load. If you specify a file tag (usually file/csv), the node will only use files with that tag.

Custom String

Use the string data from the parm CSV. This can be copy and pasted CSV, or an expression to get the data from an upstream attribute.

File Path

When Custom File Path is selected, specify the path of a single CSV file to load from (this field does not support file patterns).

File Tag

When CSV Source is “Upstream Output Files”, read CSV data from files in the output attributes of the upstream work item if they have this file tag.

CSV

CSV text to parse. Available when CSV Source is “Custom String”.

Has Header Row

Turn this on if your CSV file(s) has/have a header row (containing column names). If you extract individual rows, the node uses this to ignore the header row (otherwise it will take it as data). If you select Extract all, the node will use the header to name the attributes.

Escape Double Quotes

Determines how the CSV parser handles double quotes, e.g. a row that contains "" in one of its fields. By default, double quotes will be treated an escaped quotation mark character, and will be replaced with a single quoteation mark in the parsed row. If this toggle is disabled, then a double quote sequence will be parsed as two independent characters.

Limit Rows

Artificially limit the number of work items this node creates. The node reads the input rows sequentially as usual but simply stops at the given number of work items. This might be useful if you're worried about huge CSV files might be produced accidentally by a runaway process, or if CSV files are generated by humans and there’s a convention that they may not contain more than a certain number of items. However, you should remember that this setting can make the node silently discard legitimate data.

Work Item Index

Select how work item indexes are set when generating from an upstream item.

Row Index

Use the CSV row index as the work item index.

Upstream Index

Use the upstream item’s index.

Column Delimiter

Turn this on to explicitly set the column-separation character. If this is not turned on, the node will try guess the delimiter character from the first few rows of the file.

Add Columns Attribute

Turn this on to specify the name of a string array attribute that will be created to store the names of the columns that are extracted from the CSV. The order of the names will match the columns in the CSV. This can be used in CSV Output node

Extraction

Select the method of specifying column extractions.

By Column Index

You will specify the 0-based index of columns to be extracted in Columns to Extract.

All

When this is on, the node copies all columns into work item attributes. The attributes created are always string attributes. If you want to properly type numeric data, you should use another mode and extract columns “manually”. If Has header row is on, the node uses the column headers to name the attributes. If Has Header Row is off, the node will make up attribute names like column_0, column_1, and so on.

By Column Name

You will specify the header name of the columns to be extracted in Columns to Extract.

By Attribute

You will supply the name of an attribute to read column names or indexes from in Input Columns Attribute.

Input Columns Attribute

When Extraction is set to By Attribute, specify the name of an attribute to read column names or index from. This attribute can be a string or integer array. Column names must match the header in the CSV file, and indexes are 0-based from left to right.

Columns to Extract

When Extraction is set to By Column Index or By Column Name, use this multiparm to set up mappings between input column names or indexes to and attribute names/types.

CSV Column Index

The column number to read the data from. The first column is number 0, the second column is number 1, and so on.

CSV Column Name

The column header name from the CSV file to read data from.

Attribute Name

The name of the attribute to assign the value to.

Value Index

Attributes can have multiple values (to accommodate vectors and lists). You can set this to control at what position the value is inserted in the attribute value list.

Type

The data type of the extracted value (string, integer, or float).

Processor

Generate When

Determines when this node will generate work items. You should generally leave this set to “Automatic” unless you know the node requires a specific generation mode, or that the work items need to be generated dynamically.

All Upstream Items are Generated

This node will generate work items once all of the input nodes have generated their work items.

All Upstream Items are Cooked

This node will generate work items once all of the input nodes have cooked their work items.

Each Upstream Item is Cooked

This node will generate work items each time a work item in an input node is cooked.

Automatic

The generation mode is selected based on the generation mode of the input nodes. If any of the input nodes are generating work items when their inputs cook, this node will be set to Each Upstream Item is Cooked. Otherwise, it will be set to All Upstream Items are Generated.

Examples

ReadCSV Example for CSV Input TOP node

This example demonstrates how to read in data from CSV files. The CSV Input node will read CSV files and create 1 workitem per row.

See also

TOP nodes