Dataview: How do I use "contain" if there are two true options?

Topic

Summary
  • How to transform a country code into a flag emoji?

Test

Summary
  • dataview: v0.5.46

Input

Summary

dictionary files:

Summary
  • Location: “100_Project/02_dataview/Q20_Flags/Q20_test_data”

folder: 03

  • filename : dic_19800301 (GB=United Kingdom)
---
Date: 1980-03-01
Country: "GB"
---




folder: 04

  • filename : dic_19800401 (US=United States)
---
Date: 1980-04-01
Country: "US"
---




folder: 05

  • filename : dic_19800501
---
Date: 1980-05-01
Country: ["US", "GB"]
---




PNG files:

  • all the worlds flags in PNG format : used by DQL20
Summary
  • Location: “999_Test/Q20_test_data02”

folder: png100px

  • filename : gb.png, us.png, and so on

Screenshots(PNG_preview)


DQL10_transform_country_code_into_flag_icon_from_HTML_Hex_and_TABLE

Summary

Main DQL

Code Name Data type Group By Purposes Remark
DQL10
_transform
_country_code
_into
_flag_icon
_from_HTML_Hex
_and_TABLE
Country:
1.a string
2.a list of strings
no 1.To filter by Country
2.To sort by file.link in ascending order
3.To display the result as a table
For Windows OS:

1.To require NotoColorEmojiLimited.css
2.To enable the CSS snippet

Notes

Summary

Q1: How do I view country flags on Windows 10 through HTML?

Summary_Q1

A1

Steps:
  • Suppose that your vault is note_a8.
  • Copy the following css file into the folder note_a8/.obsidian/snippets.
  • Settings/Appearances/CSS snippets: enable it.
Screenshots(DQL10_A1)
Summary_DQL10_A1

CSS file: using online NotoColorEmoji.ttf
Summary_CSS file
  • filename : NotoColorEmojiLimited.css
```CSS
/*
Problems: How do I view country flags on Windows 10 through HTML?
https://stackoverflow.com/questions/62729729/how-do-i-view-country-flags-on-windows-10-through-html
*/

/*
Solutions: answered Nov 18, 2021 at 14:48 By Felipe Saldanha

Use [Noto Color Emoji font](https://github.com/googlefonts/noto-emoji).

First, write a `@font-face` rule with the `unicode-range` property. Then add the font to the top of your font stack:
([Source](https://prinsfrank.nl/2021/01/25/Non-existing-flag-emojis-on-windows))
*/

@font-face {
  font-family: NotoColorEmojiLimited;
  unicode-range: U+1F1E6-1F1FF;
  src: url(https://raw.githack.com/googlefonts/noto-emoji/main/fonts/NotoColorEmoji.ttf);
}

div {
  font-family: 'NotoColorEmojiLimited', -apple-system, BlinkMacSystemFont, 
  'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 
  'Segoe UI Emoji', 'Segoe UI Symbol';
}



```

Code DQL10_transform_country_code_into_flag_icon_from_HTML_Hex_and_TABLE

Summary_code
title: DQL10_transform_country_code_into_flag_icon_from_HTML_Hex_and_TABLE =>0.For Windows OS:To require `NotoColorEmojiLimited.css` and To enable the CSS snippet 1.To filter by `Country` 2.To sort by `file.name` in ascending order 3.To display the result as a table
collapse: close
icon: 
color: 
```dataview
TABLE WITHOUT ID
      file.link AS "FILE",
      join(Country, " ") AS "Country",
      
      join(
          map(
              choice(typeof(Country) = "array", Country, list(Country)), 
                  (e) => 
                      {
                        "US": "🇺🇸",
                        "GB": "🇬🇧",
                        "JP": "🇯🇵",
                        "IN": "🇮🇳",
                        "CA": "🇨🇦",
                        "CL": "🇨🇱",
                        "IT": "🇮🇹",
                        "SI": "🇸🇮",
                        "AR": "🇦🇷",   
                        "DE": "🇩🇪",
                        "AT": "🇦🇹",
                        "PL": "🇵🇱",
                        "MY": "🇲🇾",
                        "FR": "🇫🇷",
                        "CN": "🇨🇳",
                        "NG": "🇳🇬",
                        "KE": "🇰🇪",
                        "AU": "🇦🇺",
                        "BD": "🇧🇩",
                        "NZ": "🇳🇿",
                        "HK": "🇭🇰",
                        "ES": "🇪🇸"
                      }[e]     
              )
           , " ")
          AS "Flag"

FROM "100_Project/02_dataview/Q20_Flags/Q20_test_data"
WHERE Country
SORT file.name ASC

```

Screenshots(DQL10): NotoColorEmojiLimited.css used on win7(or win10)

Summary_A

)


Screenshots(DQL10): NotoColorEmojiLimited.css not used on win7(or win10)

Summary_B


DQL20_transform_country_code_into_flag_icon_from_PNG_and_TABLE

Summary

Main DQL

Code Name Data type Group By Purposes Remark
DQL20
_transform
_country_code
_into
_flag_icon
_from_PNG
_and_TABLE
Country:
1.a string
2.a list of strings
no 1.To filter by Country
2.To sort by file.name in ascending order
3.To display the result as a tableThe PNG
To require all the worlds flags in PNG format: download this repository

Notes

Summary

Q1: What is a country flag emoji?

from: SVG and PNG renders of all countries’ flags. >> Readme

Summary_Q1

A1

A country flag emoji is organized by an “ISO country-code”
  • The flags are named by their 2-letter ISO-3166 country code, except for the
    constituent countries of Great Britain which have 6-letter codes “GB-ENG” etc).

  • Kosovo uses the user-assigned country code XK, which is not part of the ISO standard, but in use by several multinational organizations.

  • Also included is a JSON file that maps the ISO country code to the name of the
    country.


Q2: How to get all country flag images?

from: SVG and PNG renders of all countries’ flags. >> Readme

Summary_Q2

A2


Code DQL20_transform_country_code_into_flag_icon_from_PNG_and_TABLE

Summary_code
title: DQL20_transform_country_code_into_flag_icon_from_PNG_and_TABLE =>0.To require all the worlds flags in PNG format: [download this repository](https://github.com/hampusborgos/country-flags/archive/refs/heads/main.zip) 1.To filter by `Country` 2.To sort by `file.link` in ascending order 3.To display the result as a table
collapse: close
icon: 
color: 
```dataview
TABLE WITHOUT ID
      file.link AS "FILE",
      Country AS "Country",     

      map(
          choice(typeof(Country) = "array", Country, list(Country)), 
              (e) => 
                  embed(link("999_Test/Q20_test_data02/png100px/" + lower(e) + ".png"))                  
          )
      AS "Flag"

FROM "100_Project/02_dataview/Q20_Flags/Q20_test_data"
WHERE Country

SORT file.name ASC

```

Screenshots(DQL20)


Reference

Summary

used by DQL10 or DQL20

used by DQL10

Emoji Flags

  • The following order is the same as that of ReaderGuy42’s nested choice statement.
Summary_Flags

used by DQL20