Summary of input in a list

Hello,
I am new in the community and have been loving Blaze but I am stuck on a new project!

I have as an input a text as below.
Date : 2025-02-02
Cholestérol total : 3515,4 mmol/L
Triglycérides : 2,03 mmol/L
Cholestérol HDL : 0,93 mmol/L

Date : 2025-02-04
Cholestérol total : 4 mmol/L
Triglycérides : 3 mmol/L
Cholestérol HDL : 0,93 mmol/L

============

The variable which is Cholestérol total, Triglycérides and Cholestérol HDL can vary from different report I received. Sometime there is a new variable like Hemoglobin but it will alway be on a new line.

So I am trying to extract the numerical value from each variable with the associated date and after to be able to get an output will show a trend. Here an example

Cholestérol total : 3515,4 (2025-02-02) ← 4 (2025-02-04)
Triglycérides : 2,03 (2025-02-02) ← 3 (2025-02-04)
Cholestérol HDL : (2025-02-02) ← 0,93 (2025-02-04)

I tried extractregex and input into data blaze. But I am having difficulty.

If anyone have an idea which command should I try?
I think the formula map could help and the formula list.

Thank you!

Hey @robertremblay ,
Does something like this works?

I used extract regex with a caputre and for Hameglobin I used catch() to default it to empty text if not found.

{txt="
Date : 2025-02-02
Cholestérol total : 3515,4 mmol/L
Triglycérides : 2,03 mmol/L
Cholestérol HDL : 0,93 mmol/L
"}
For date {=replace(extractregex(txt, "Date\s*:\s*([\d-]+)"), ",", ".")}
Cholestérol Total is {=replace(extractregex(txt, "Cholestérol total\s*:\s*([\d,]+)"), ",", ".")}
Triglycérides is {=replace(extractregex(txt, "Triglycérides\s*:\s*([\d,]+)"), ",", ".")}
Cholestérol HDL is {=replace(extractregex(txt, "Cholestérol HDL\s*:\s*([\d,]+)"), ",", ".")}
{hemaglobin=catch(replace(extractregex(txt, "Hemoglobin\s*:\s*([\d,]+)"), ",", "."), "")}{if: hemaglobin<>""}Hemaglobin is {=hemaglobin}{endif}

{txt="
Date : 2025-02-04
Cholestérol total : 4 mmol/L
Triglycérides : 3 mmol/L
Cholestérol HDL : 0,93 mmol/L
"}
For date {=replace(extractregex(txt, "Date\s*:\s*([\d-]+)"), ",", ".")}
Cholestérol Total is {=replace(extractregex(txt, "Cholestérol total\s*:\s*([\d,]+)"), ",", ".")}
Triglycérides is {=replace(extractregex(txt, "Triglycérides\s*:\s*([\d,]+)"), ",", ".")}
Cholestérol HDL is {=replace(extractregex(txt, "Cholestérol HDL\s*:\s*([\d,]+)"), ",", ".")}
{hemaglobin=catch(replace(extractregex(txt, "Hemoglobin\s*:\s*([\d,]+)"), ",", "."), "")}{if: hemaglobin<>""}Hemaglobin is {=hemaglobin}{endif}

{txt="
Date : 2029-03-25
Cholestérol total : 42 mmol/L
Triglycérides : 2,35 mmol/L
Cholestérol HDL : 0,99 mmol/L
Hemoglobin : 13,9
"}
For date {=replace(extractregex(txt, "Date\s*:\s*([\d-]+)"), ",", ".")}
Cholestérol Total is {=replace(extractregex(txt, "Cholestérol total\s*:\s*([\d,]+)"), ",", ".")}
Triglycérides is {=replace(extractregex(txt, "Triglycérides\s*:\s*([\d,]+)"), ",", ".")}
Cholestérol HDL is {=replace(extractregex(txt, "Cholestérol HDL\s*:\s*([\d,]+)"), ",", ".")}
{hemaglobin=catch(replace(extractregex(txt, "Hemoglobin\s*:\s*([\d,]+)"), ",", "."), "")}{if: hemaglobin<>""}Hemaglobin is {=hemaglobin}{endif}

Thank you for the input! It is appreciated! Actually the goal is really to combine both list and be able to see the trend between multiple dates.

I was able to do it but it is only working with 2 dates and only 3 variables!

But it is not modular, so if I have more dates or more variable it is not taking them.

the input text is :

Date : 2025-02-02
Cholestérol total : 3515,4 mmol/L
Triglycérides : 2,03 mmol/L
Cholestérol HDL : 0,93 mmol/L

Date : 2025-02-04
Cholestérol total : 4 mmol/L
Triglycérides : 3 mmol/L
Cholestérol HDL : 0,93 mmol/L

But it is not working if for example it is : Date : 2025-02-02
Cholestérol total : 3515,4 mmol/L
Triglycérides : 2,03 mmol/L
Cholestérol HDL : 0,93 mmol/L

Date : 2025-02-04
Cholestérol total : 4 mmol/L
Triglycérides : 3 mmol/L
Cholestérol HDL : 0,93 mmol/L

Date : 2025-02-09
Cholestérol total : 2 mmol/L
Triglycérides : 5 mmol/L
Hemoglobin : 120 mmol/L

=========================

{formparagraph: name=Input Text; default=Date : 2025-02-02
Cholestérol total : 3515,4 mmol/L
Triglycérides : 2,03 mmol/L
Cholestérol HDL : 0,93 mmol/L

Date : 2025-02-04
Cholestérol total : 4 mmol/L
Triglycérides : 3 mmol/L
Cholestérol HDL : 0,93 mmol/L}

{dates=extractregexall(Input Text, "Date : (\d{4}-\d{2}-\d{2})")}
{cholesterol_total=extractregexall(Input Text, "Cholestérol total : ([\d,]+) mmol/L")}
{triglycerides=extractregexall(Input Text, "Triglycérides : ([\d,]+) mmol/L")}
{cholesterol_hdl=extractregexall(Input Text, "Cholestérol HDL : ([\d,]+) mmol/L")}

Cholestérol total : {=cholesterol_total[1]} ({=dates[1]}) ← {=cholesterol_total[2]} ({=dates[2]})
Triglycérides : {=triglycerides[1]} ({=dates[1]}) ← {=triglycerides[2]} ({=dates[2]})
Cholestérol HDL : {=cholesterol_hdl[1]} ({=dates[1]}) ← {=cholesterol_hdl[2]} ({=dates[2]})

Hi @robertremblay ,
Thanks for the full example.
Here is the snippet which should get the result you need

{formparagraph: name=Input Text; default=Date : 2025-02-02
Cholestérol total : 3515,4 mmol/L
Triglycérides : 2,03 mmol/L
Cholestérol HDL : 0,93 mmol/L

Date : 2025-02-04
Cholestérol total : 4 mmol/L
Triglycérides : 3 mmol/L
Cholestérol HDL : 0,93 mmol/L

Date : 2025-02-09
Cholestérol total : 2 mmol/L
Triglycérides : 5 mmol/L
Hemoglobin : 120 mmol/L; rows=15; cols=40}
{note: preview=no}
{parts=splitregex(`Input Text`, "\n[\n]+")}

{dates=map(parts, (part) -> extractregex(part, "Date : (\d{4}-\d{2}-\d{2})"))}
{cholesterol_total=map(parts, (part) -> extractregex(part, "Cholestérol total : ([\d,]+) mmol/L"))}
{triglycerides=map(parts, (part) -> extractregex(part, "Triglycérides : ([\d,]+) mmol/L"))}
{cholesterol_hdl=map(parts, (part) -> catch(extractregex(part, "Cholestérol HDL : ([\d,]+) mmol/L"), "NA"))}
{hemaglobin=map(parts, (part) -> catch(extractregex(part, "Hemoglobin : ([\d,]+) mmol/L"), "N/A"))}
{endnote}
Cholestérol total : {=join(map(dates, (date, index) -> cholesterol_total[index] & " (" & date & ")"), " ← ")}
Triglycérides : {=join(map(dates, (date, index) -> triglycerides[index] & " (" & date & ")"), " ← ")}{=triglycerides[1]}
Cholestérol HDL : {=join(map(dates, (date, index) -> cholesterol_hdl[index] & " (" & date & ")"), " ← ")}
Hemoglobin: {=join(map(dates, (date, index) -> hemaglobin[index] & " (" & date & ")"), " ← ")}

I have use split with more two new lines to split each section.
Then used map() to find the value I need those parts.

Wow! Thank you so much! I will continu working on it I have a couple idea with adding "if" to automatically only output variable of the report! I will post it when I am done!

1 Like