text: user16935: 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
  
  user10775: 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
  
  
  
original_text: 16935: <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>
   10775: <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>
  