read_int

Read a file as an integer

Int read_int(File)

Reads a file that contains a single line containing only an integer and (optional) whitespace. If the line contains a valid integer, that value is returned as an Int. If the file is empty or does not contain a single integer, an error is raised.

Parameters

  1. File: Path of the file to read.

Returns: An Int.

Example: read_int_task.wdl

version 1.3

task read_int {
  command <<<
  printf "  1  \n" > int_file
  >>>

  output {
    Int i = read_int("int_file")
  }
}

Example input:

{}

Example output:

{
  "read_int.i": 1
}