# Sample Sheets and the dynamic creation of Files

**URL:** <https://cwl.discourse.group/t/sample-sheets-and-the-dynamic-creation-of-files/1002>\
**Category:** CWL Questions\
**Created:** [May 12, 2025, 2:07pm UTC](https://cwl.discourse.group/t/sample-sheets-and-the-dynamic-creation-of-files/1002 "2025-05-12T14:07:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![markjschreiber](https://yyz2.discourse-cdn.com/free1/user_avatar/cwl.discourse.group/markjschreiber/32/592_2.png) [@markjschreiber](https://cwl.discourse.group/u/markjschreiber)\
**Post date:** [May 12, 2025, 2:07pm UTC](https://cwl.discourse.group/t/sample-sheets-and-the-dynamic-creation-of-files/1002/1 "2025-05-12T14:07:55Z")

</div>

Apologies if this is a repeat. I found some much older questions on this but the solutions appear to be work arounds for older schemas and links are broken.

My question is - I have a csv input (a sample sheet) with pairs of FASTQ file paths in the form  
`sampleName,path/to/file1,path/to/file2`

I want to extract `path/to/file1` and `path/to/file2` and output those as `File` types so that they can be consumed by a downstream task that requires `File` inputs.

What is the most idiomatic way to do this in CWL 1.2?

---

<div class="post-metadata">

**Author:** ![alexiswl](https://yyz2.discourse-cdn.com/free1/user_avatar/cwl.discourse.group/alexiswl/32/93_2.png) [@alexiswl](https://cwl.discourse.group/u/alexiswl)\
**Post date:** [May 19, 2025, 11:38am UTC](https://cwl.discourse.group/t/sample-sheets-and-the-dynamic-creation-of-files/1002/2 "2025-05-19T11:38:34Z")

</div>

Hi Mark,

Does the CSV comprise multiple rows?

## Generate the schema

File name schema.yaml

```yaml
type: record
name: fastq-pair

fields:
  sampleName:
    label: sample name
    doc: |
      The name of the sample
    type: string
  read1File:
    label: read 1
    doc: |
      The read 1 file object
    type: File
  read2File:
    label: read 2
    doc: |
     The read 2 file object
    type: File?

```

## Tool

When building the Schema def requirement, import the schema with the following

```auto
requirements:
  InlineJavascriptRequirement: {}
  SchemaDefRequirement:
    types:
      - $import: schema.yaml

```

Then in the output section, you will need to use ‘loadContents’

```yaml
outputs:
  fastqPairObjects:
    label: fastq pair objects
    doc: |
      The fastq pair objects
    # Syntax is schema-path#schema-name
    # Added [] because we will be expecting an array of this type
    type: schema.yaml#fastq-pair[]
    outputBinding:
       glob: "samplesheet.csv"
       loadContents: true
       outputEval: |
         ${
            var content_lines = self[0].contents.split("\n");
            fastq_pair_objects = [];
            content_lines.forEach(function (value, i) {
               fastq_pair_objects.push(
                 {
                    "sampleName": content_lines.split(",")[0]
                    "read_1": {
                       "class": "File",
                       "path": content_lines.split(",")[1]
                    },
                    "read_2": {
                       "class": "File",
                       "path": content_lines.split(",")[2]
                    },
                 }
               );
            });
            return fastq_pair_objects;
         }

```

Hope that points you in the right direction!
