How to access/print elements of a map?

Hello there,

I read a eight columnar CSV file. The data look like as the below:




I’d like to access/print elements of the map, say for example, time_point

Below is my code:

workflow {

.splitCsv(sep: ‘,’)
.map { row →
// Extract relevant information
def sample_ID = row[0]
def normal_Reads = tuple(file(row[1]), file(row[2]))
def tumor_Reads = tuple(file(row[3]), file(row[4]))
def rna_Reads = tuple(file(row[5]), file(row[6]))
def time_Point = row[7]

        // Return a map with the processed information
        return [sample_name: sample_ID, normal: normal_Reads, tumor: tumor_Reads, rna: rna_Reads, time_point: time_Point]
    .set { samples }

samples.view { “$it” }
//samples[‘sample_name’].view { “$it” }


I print complete map using .view

You can print the value for the sample_name key the following way:

samples.view { "${it.sample_name}" }


Thank you. It worked.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.