Trying to use dictionary 🤪

Hi friends!!

I'm trying to use (diabolic :stuck_out_tongue_winking_eye:) dictionary and I am decided to learn a bit more about this.

I'm getting data from API airtable and I usually transform each field into different list (Item-> 1º list, cost-> 2ºlist....) using this block:
imagen

but now, I need to sort the data by one field using sort list block:


(by the way, this block work fine with this "list")

So i need the data in 1 list.

I'm trying several ways to get it, but, I can get a List. This is my blocks.

And this is the list what I get:

It's not a dictionary either.

When I try to get an item from the List I just created, I get an error.

This is text file with the first 10 item directly from Airtable.

downloadData.txt (3.2 KB)

How should I do it?

Thanks in advance.

List sort blocks do not sort dictionaries.

You need to turn your dictionaries into tables (lists of lists)

2 Likes

Yes, for this I make the list with all data from airtable. The sort block works, but select item block do not work

There is another list sort block that lets you provide your own comparison test.
blocks (1)

Also, how do you handle short rows?

1 Like

These procedures can extract well behaved tables from arbitrary structures.

1 Like

Which field is item 4?
1#77 (IdCatArt) ?

That would require a string comparison for sorting, since it is not a number.

1 Like

Here is a result for your JSON text:

Do It Result: ""createdTime","ActivoArt","ArticuloOculto","DESCART","IdCatArt","OFERTA","PVPArt","UndVtaArt","UrlFotoArt","id"
"2023-03-27T14:22:56.000Z","not found","not found","not found","not found","not found","not found","not found","not found","recTOn7We1mD4YUa0"
"2023-03-27T14:24:12.000Z","1","0","1/2 k. filetes de cerdo + 1/2 k. Ternera guisar","77","1","9,95","UND","https://res.cloudinary.com/doi1k0pjg/image/upload/v1679926975/borrar_kbmtst.jpg","recLIbr7qu2F1D5FS"
"2023-03-27T14:25:10.000Z","1","0","1k. chuletas de cerdo + 1k. costillas tiras","77","1","13,95","UND","https://res.cloudinary.com/doi1k0pjg/image/upload/v1679927051/borrar_jbwnyd.jpg","recIp01DoD6wTHR3g"
"2023-03-27T14:21:25.000Z","1","0","1k. Cinta de lomo + 1k. Hamburguesas ","77","1","13,95","UND","https://res.cloudinary.com/doi1k0pjg/image/upload/v1679927109/borrar_o4a8he.jpg","recG8zC2fs8OsloQ7"
"2023-09-25T08:06:07.000Z","1","0","1k. Solomillo de cerdo + 1k. filetes de pavo ","77","1","9,95","UND","https://res.cloudinary.com/doi1k0pjg/image/upload/v1679926884/borrar_sh6fqc.jpg","rec4ZO6deiN8UU4ey"
"2022-10-18T16:57:22.000Z","0","0","borra","77","0","5","UND","https://res.cloudinary.com/doi1k0pjg/image/upload/v1695629164/app_inventor_1695629144645_tzxrgt.jpg","recmnktV8apL70WhP"
"2022-08-22T12:18:00.000Z","1","0","carrillada+iberica","84","0","13,95","KG","https://res.cloudinary.com/doi1k0pjg/image/upload/v1666112241/IMG_20221018_185640_wqbcao.jpg","recovJPFH9bN4pbEt"
"2022-09-19T18:04:31.000Z","1","0","Chuletas+de+lomo+iberico","84","0","14,95","KG","https://res.cloudinary.com/doi1k0pjg/image/upload/v1661170679/icgziapsp0etszsja94t.jpg","recLlQ4IxkpSwCuGz"
"2022-08-22T12:23:40.000Z","1","0","Lagarto+de+cerdo+iberico","84","0","19,80","KG","https://res.cloudinary.com/doi1k0pjg/image/upload/v1664114830/DeliverAPP/dxdc16uyvhzwqwqayuz9.jpg","rec6fLhzOLZhXqZaF"
"2022-08-22T11:53:17.000Z","1","0","Presa+iberica","84","0","32,00","KG","https://res.cloudinary.com/doi1k0pjg/image/upload/v1661171019/eoksguatk8esfijcs7lp.jpg","recQSp2sOkHUk1XqC"
"
---

using this extraction call:


extract_table.aia (5.6 KB)

1 Like

Short rows?

Yes, is the category's Item. But, the first number before # is the fist sorting number. I do this to sort item by categorys but each category has an sort number to on screen selected by user. (Sorry ror my English)

Ok, I try it!

Thanks!!

Sorry, I notice my code is not converting the list of dictionaries to a table properly.
The first item is offset vertically, resulting in missing data in row 1 and wrong createdTime.

I will have to study it.

Also, the # characters in your sort field seem to have disappeared from your IdCatArt, making any sample code on how to sort on that field irrelevant.

To specify a sort comparison on the combination of fields, use logical AND and OR blocks:
if first part of left side < first part of second side, then less,
else if first part of left side = first part of second side, then compare second parts.

1 Like

I have isolated my bug to the case where the first column is taken from the parent dictionary of the subdictionary containing the rest of the desired keys.

The code works if you omit that createdTime field:

Do It Result: ""ActivoArt","ArticuloOculto","DESCART","IdCatArt","OFERTA","PVPArt","UndVtaArt","UrlFotoArt","id"
"1","0","1/2 k. filetes de cerdo + 1/2 k. Ternera guisar","77","1","9,95","UND","https://res.cloudinary.com/doi1k0pjg/image/upload/v1679926975/borrar_kbmtst.jpg","recLIbr7qu2F1D5FS"
"1","0","1k. chuletas de cerdo + 1k. costillas tiras","77","1","13,95","UND","https://res.cloudinary.com/doi1k0pjg/image/upload/v1679927051/borrar_jbwnyd.jpg","recIp01DoD6wTHR3g"
"1","0","1k. Cinta de lomo + 1k. Hamburguesas ","77","1","13,95","UND","https://res.cloudinary.com/doi1k0pjg/image/upload/v1679927109/borrar_o4a8he.jpg","recG8zC2fs8OsloQ7"
"1","0","1k. Solomillo de cerdo + 1k. filetes de pavo ","77","1","9,95","UND","https://res.cloudinary.com/doi1k0pjg/image/upload/v1679926884/borrar_sh6fqc.jpg","rec4ZO6deiN8UU4ey"
"0","0","borra","77","0","5","UND","https://res.cloudinary.com/doi1k0pjg/image/upload/v1695629164/app_inventor_1695629144645_tzxrgt.jpg","recmnktV8apL70WhP"
"1","0","carrillada+iberica","84","0","13,95","KG","https://res.cloudinary.com/doi1k0pjg/image/upload/v1666112241/IMG_20221018_185640_wqbcao.jpg","recovJPFH9bN4pbEt"
"1","0","Chuletas+de+lomo+iberico","84","0","14,95","KG","https://res.cloudinary.com/doi1k0pjg/image/upload/v1661170679/icgziapsp0etszsja94t.jpg","recLlQ4IxkpSwCuGz"
"1","0","Lagarto+de+cerdo+iberico","84","0","19,80","KG","https://res.cloudinary.com/doi1k0pjg/image/upload/v1664114830/DeliverAPP/dxdc16uyvhzwqwqayuz9.jpg","rec6fLhzOLZhXqZaF"
"1","0","Presa+iberica","84","0","32,00","KG","https://res.cloudinary.com/doi1k0pjg/image/upload/v1661171019/eoksguatk8esfijcs7lp.jpg","recQSp2sOkHUk1XqC"
"
---


extract_table.aia (5.8 KB)

2 Likes

HI!! Finally I got it with the next blocks.

I get data from airtable and then I add each record to List: TABLA_ARTICULOS

(in the collapsed block is where I add the classification number it should have)

I need to sort the table (list of list from airtable) with field IdCatArt. 9-99 -> 9= sort number - 99 category.

I hope this help to other like me.

Thanks for your help @ABG !! :beers:

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