I have a table like this:
╭─────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 0 │ ╭───┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │ │ 0 │ 2023-09-22 17:49:03.301 │ │
│ │ │ 1 │ INFO: 10.0.0.30:49398 - "GET ..." 200 OK │ │
│ │ ╰───┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ 1 │ ╭───┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │ │ 0 │ 2023-09-22 17:44:11.024 │ │
│ │ │ 1 │ INFO: 10.0.2.177:15974 - "GET ..." 404 │ │
│ │ ╰───┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ 2 │ ╭───┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │ │ 0 │ 2023-09-22 17:44:11.024 │ │
│ │ │ 1 │ INFO: 10.0.0.30:47184 - "GET ..." 500 │ │
│ │ ╰───┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
How can I merge line 1 for each cells if the date from line 0 is the same? To add more context it's a display of AWS logs and I want to merge the lines that are from the same request (so with the same timestamp) to have a better view of the logs.
In the example above I would like to have a new table (or the previous one updated) to have something like this:
╭─────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 0 │ ╭───┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │ │ 0 │ 2023-09-22 17:49:03.301 │ │
│ │ │ 1 │ INFO: 10.0.0.30:49398 - "GET ..." 200 OK │ │
│ │ ╰───┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ 1 │ ╭───┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │ │ 0 │ 2023-09-22 17:44:11.024 │ │
│ │ │ 1 │ INFO: 10.0.2.177:15974 - "GET ..." 404 │ │
| | | | INFO: 10.0.0.30:47184 - "GET ..." 500 │ │
│ │ ╰───┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
Assuming, the underlying data structure is two nested arrays of strings like below:
Then, you can use
group-byto group the input array by their first items (the date lines) using column0, then iterate over the groups usingitemsto capture both their grouping key (the date) and the array of input values grouped together. Foreach, take the latter, skip over their first items (the common date lines) usingskipwith amout1, andflattenout their contents. Finally,prependthe captured dates to each group: