#help on function for table

37 messages · Page 1 of 1 (latest)

iron orchid
#

HI,
Im trying to setup custom table template beacuse i have a bunch of them but im doing something wrong...
Thanks a lot guys you are amazing!

#let results = csv("results/test1.csv")

#let restable(data) = {
  fr = data.slice(1).flatten().map(r => [#calc.round(float(r), digits: 2)])
  table(
    columns: 9,
    align: center,
    [$P_"max"("MPa")$],[$P_"max"("deg")$],[$M_"fuel"("mg")$],[$lambda$],[$P("kW")$],[$T_"ex"(K)$],[$"CAD10"$],[$"CAD50"$],[$"CAD90"$],
    ..fr
)
}

#restable(results)
sudden timber
#

whats the error?

iron orchid
#

type content has no method slice

sudden timber
#

do #restable(results)

#

not the square brackets

#

square brackets indicate the content type meaning you passed the word "results" in a Content

#

normal parentheses is what u want here

iron orchid
#

no something isnt right at the function... im doing something wrong

sudden timber
#

you still want to switch to parentheses

iron orchid
#

i switched

sudden timber
#

whats the new error

iron orchid
#

array index out of bound

iron orchid
sudden timber
#

put a let in front of the fr

iron orchid
#

still index out of bounds

sudden timber
#

not on my end, your csv must be wrong then

#

how does it look

iron orchid
#

without the function it is working great

#

I can send it here

sudden timber
#

do that

iron orchid
sudden timber
#

works perfect for me

iron orchid
#

you just added the let before the fr?

sudden timber
#

it shouldnt even compile without the let

iron orchid
#

you can send please what you wrote?
for me it dosent work on the website and even locally

sudden timber
#

so either your compile environment is caching something wrong, or your document has a diff error somewhere else you need to fix first

iron orchid
#

on empty document..

sudden timber
#
#let results = csv("test.csv")

#let restable(data) = {
  let fr = data.slice(1).flatten().map(r => [#calc.round(float(r), digits: 2)])
  table(
    columns: 9,
    align: center,
    [$P_"max"("MPa")$],[$P_"max"("deg")$],[$M_"fuel"("mg")$],[$lambda$],[$P("kW")$],[$T_"ex"(K)$],[$"CAD10"$],[$"CAD50"$],[$"CAD90"$],
    ..fr
  )
}

#restable(results)
#

is it the only document in your project?

iron orchid
#

im trying to send an image

sudden timber
#

can you try reloading the website without cookies, like ctrl + f5?

iron orchid
#

Im so dumb, thanks it works now!

sudden timber
#

must have been something cached wrong

iron orchid
#

yeah

#

thanks a lot! god bless you!!