<p>I think the problem is just that you have extra whitespace at the end of the first line in your CSV file. Either remove the whitespace manually, or use the <code>strip</code> parameter with the <a href="https://www.nextflow.io/docs/latest/operator.html#splitcsv" rel="nofollow noreferrer"><code>splitCsv</code></a> operator to remove leading and trailing whitespace from values. For example:</p>
<pre><code>params.file = './file.csv'


process test_proc {

    input:
    tuple val(digits), val(values)

    output:
    path &quot;dig_${values}.txt&quot;

    &quot;&quot;&quot;
    echo &quot;<span class="math-container">${digits}" &gt; "dig_$</span>{values}.txt&quot;
    &quot;&quot;&quot;
}

workflow { 
 
    Channel.fromPath( params.file ) \
        | splitCsv( header:true, strip:true ) \
        | map { row -&gt;
            tuple( row.dig, row.val )
        } \
        | test_proc \
        | view()

}
</code></pre>
<p>Results:</p>
<pre><code>$ nextflow run main.nf 
N E X T F L O W  ~  version 22.10.0
Launching `main.nf` [stupefied_boyd] DSL2 - revision: 2a9d8dc414
executor &gt;  local (5)
[4f/a73196] process &gt; test_proc (2) [100%] 5 of 5 ✔
/path/to/work/9d/4905d0236788c1a3733da5358b7fc4/dig_Four.txt
/path/to/work/f9/d04e8a1c2265d73cde626703317df7/dig_Five.txt
/path/to/work/ff/522238f87a5641fdc7adce3e4d1cea/dig_Three.txt
/path/to/work/e9/9b7ec2a65d45986fd8944da4a2054c/dig_One.txt
/path/to/work/4f/a73196fbd56db3c9647fa7b072edfd/dig_Two.txt

</code></pre>

CC BY-SA 4.0
2023-02-13T15:58:05.403Z
Hey thank you so much for the answer, it seems that your answer is not solving my problem, I wonder if my test file is causing this. thank you so much for the help
Loïc Borcard
CC BY-SA 4.0
2023-02-13T23:40:26.393Z
@LoïcBorcard So what is the problem exactly? What are you trying to achieve or what are you expecting?
Steve
CC BY-SA 4.0
2023-02-09T15:27:17.020Z
2023-02-09T15:27:17.020Z
Steve
<p>I am trying to create a channel with a CSV file and use it as tuple input. Yet the output I obtain does not contain the entire file but only the first element of the file (1st row).</p>
<p><strong>the csv</strong></p>
<pre><code>dig,val 
1,One
2,Two
3,Three
4,Four
5,Five
</code></pre>
<p>output :
<code>cat digOne.txt</code>
<code>1 </code>
instead of the whole collection
digOne, digTwo...</p>
<pre><code>
 size_amp_ch = Channel
        .fromPath( params.file)
        .splitCsv(header:true).map{
            row  -&gt; tuple(row.dig,row.val)
        }

process{
    input:

    tuple val(digits), val(values)
    
    output:


    path &quot;dig_${values}.txt&quot;

    script:

    &quot;&quot;&quot;
    echo <span class="math-container">$digits &gt;&gt; dig_$</span>{values}.txt


}

</code></pre>
<p>thank you</p>

<nextflow><workflow-management>
Nextflow tuple from CSV cols
# Nextflow tuple from CSV cols

(Asked by: username_0 on 2023-02-09)

I am trying to create a channel with a CSV file and use it as tuple input. Yet the output I obtain does not contain the entire file but only the first element of the file (1st row).
the csv
dig,val 
1,One
2,Two
3,Three
4,Four
5,Five

output :
cat digOne.txt
1 
instead of the whole collection
digOne, digTwo...

 size_amp_ch = Channel
        .fromPath( params.file)
        .splitCsv(header:true).map{
            row  -> tuple(row.dig,row.val)
        }

process{
    input:

    tuple val(digits), val(values)
    
    output:


    path "dig_${values}.txt"

    script:

    """
    echo $digits >> dig_${values}.txt


}


thank you

**Tags:** nextflow, workflow-management

---

## 1 answers

### Answer by username_1 on 2023-02-09. Score: 1

I think the problem is just that you have extra whitespace at the end of the first line in your CSV file. Either remove the whitespace manually, or use the strip parameter with the splitCsv operator to remove leading and trailing whitespace from values. For example:
params.file = './file.csv'


process test_proc {

    input:
    tuple val(digits), val(values)

    output:
    path "dig_${values}.txt"

    """
    echo "${digits}" > "dig_${values}.txt"
    """
}

workflow { 
 
    Channel.fromPath( params.file ) \
        | splitCsv( header:true, strip:true ) \
        | map { row ->
            tuple( row.dig, row.val )
        } \
        | test_proc \
        | view()

}

Results:
$ nextflow run main.nf 
N E X T F L O W  ~  version 22.10.0
Launching `main.nf` [stupefied_boyd] DSL2 - revision: 2a9d8dc414
executor >  local (5)
[4f/a73196] process > test_proc (2) [100%] 5 of 5 ✔
/path/to/work/9d/4905d0236788c1a3733da5358b7fc4/dig_Four.txt
/path/to/work/f9/d04e8a1c2265d73cde626703317df7/dig_Five.txt
/path/to/work/ff/522238f87a5641fdc7adce3e4d1cea/dig_Three.txt
/path/to/work/e9/9b7ec2a65d45986fd8944da4a2054c/dig_One.txt
/path/to/work/4f/a73196fbd56db3c9647fa7b072edfd/dig_Two.txt

> **Comments:**
> **username_0**: Hey thank you so much for the answer, it seems that your answer is not solving my problem, I wonder if my test file is causing this. thank you so much for the help  
> **username_1**: @LoïcBorcard So what is the problem exactly? What are you trying to achieve or what are you expecting?  

---

