Hi,
I’m trying to create a table from data in a csv file. The first two rows and 1st column are headings which I want to color differently and this code works fine:
#let sensitivity_table = for file in sets.files {
let fileData = csv(data_dir + file + ".csv")
let numRows = fileData.len()
makefigure(
kind: table,
{
heading(file)
maketable(
fileData,
fill: (x, y) => if y < 2 or x < 1 { yellow } ,
)
},
)
}
I also want to color any cells that contain ‘nan’ red and I can’t seem to figure out the syntax. I have tried things like:
maketable(
fileData,
fill: (x, y, fileData) => {
if y < 2 or x < 1 {
yellow
}
else if fileData[y][x] == "nan" { red }
else { none }
}
)
and
maketable(
fileData,
fill: (x, y) => {
if y < 2 or x < 1 {
yellow
} else if str(fileData[y][x]).lower() == 'nan' {
red
} else {
none
}
}
)
But neither works. Does anyone know the correct syntax to do this ?
Thanks