问:
XSLT combine multiple list from one file to table
I need help with merging several tables of one file into one output.
The files that I get processed perfectly according to the XSLT schema that is listed below. But today I received an interesting file that was not processed as I wanted.

source file

```<code><?xml version="1.0" encoding="utf-8"?>
<extdata user="test">
  <scheme name="Order">
    <data>
      <s>
        <d name="CashOrder">
          <f name="ActionDate" type="Date" />
          <f name="AddressId" type="String" />
          <f name="CompanyId" type="String" />
        </d>
      </s>
      <o>
        <d name="CashOrder">
          <r>
            <f>2022-01-24T00:00:00</f>
            <f>10234</f>
            <f>10234</f>
          </r>
          <r>
            <f>2022-01-24T00:00:00</f>
            <f>52817</f>
            <f>52817</f>
          </r>
          <r>
            <f>2022-01-24T00:00:00</f>
            <f>58259</f>
            <f>58259</f>
          </r>
        </d>
      </o>
    </data>
    <data>
      <s>
        <d name="OrderOption">
          <f name="OrderDate" type="Date" />
          <f name="OrderNumber" type="String" />
        </d>
      </s>
      <o>
        <d name="OrderOption">
          <r>
            <f>2022-01-24T00:00:00</f>
            <f>WE30395.c17639</f>
          </r>
          <r>
            <f>2022-01-24T00:00:00</f>
            <f>WE30395.c17639</f>
          </r>
          <r>
            <f>2022-01-24T00:00:00</f>
            <f>WE30395.c17639</f>
          </r>
        </d>
      </o>
    </data>
  </scheme>
</extdata>
</code>```

my XSLT (here they helped me with writing.there was a problem with the recursive processing of the hierarchy)

```<code><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
   <xsl:output method="xml" indent="yes" />
   <xsl:template match="/extdata/scheme">
      <ValueTable xmlns="http://v8.1c.ru/8.1/data/core" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <xsl:for-each select="data/s/d/f | data/s/d/d/f">
            <column>
               <Name xsi:type="xs:string">
                  <xsl:value-of select="@name" />
               </Name>
               <ValueType>
                  <xsl:if test="@type= 'String'">
                     <Type>xs:string</Type>
                     <StringQualifiers>
                        <Length>150</Length>
                        <AllowedLength>Variable</AllowedLength>
                     </StringQualifiers>
                  </xsl:if>
                  <xsl:if test="@type= 'Date'">
                     <Type>xs:dateTime</Type>
                     <DateQualifiers>
                        <DateFractions>DateTime</DateFractions>
                     </DateQualifiers>
                  </xsl:if>
                  <xsl:if test="@type= 'Decimal' or @type= 'Currency'">
                     <Type>xs:decimal</Type>
                     <NumberQualifiers>
                        <Digits>20</Digits>
                        <FractionDigits>4</FractionDigits>
                        <AllowedSign>Any</AllowedSign>
                     </NumberQualifiers>
                  </xsl:if>
                  <xsl:if test="@type= 'Integer'">
                     <Type>xs:decimal</Type>
                     <NumberQualifiers>
                        <Digits>20</Digits>
                        <FractionDigits>0</FractionDigits>
                        <AllowedSign>Any</AllowedSign>
                     </NumberQualifiers>
                  </xsl:if>
               </ValueType>
            </column>
         </xsl:for-each>
         <xsl:for-each select="data/o/d/r">
            <row>
               <xsl:for-each select=".//f">
                  <Value>
                     <xsl:value-of select="." />
                  </Value>
               </xsl:for-each>
            </row>
         </xsl:for-each>
      </ValueTable>
   </xsl:template>
</xsl:stylesheet>
</code>```

output now

```<code>      <ValueTable xmlns="http://v8.1c.ru/8.1/data/core"
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <column>
      <Name xsi:type="xs:string">ActionDate</Name>
      <ValueType>
         <Type>xs:dateTime</Type>
         <DateQualifiers>
            <DateFractions>DateTime</DateFractions>
         </DateQualifiers>
      </ValueType>
   </column>
   <column>
      <Name xsi:type="xs:string">AddressId</Name>
      <ValueType>
         <Type>xs:string</Type>
         <StringQualifiers>
            <Length>150</Length>
            <AllowedLength>Variable</AllowedLength>
         </StringQualifiers>
      </ValueType>
   </column>
   <column>
      <Name xsi:type="xs:string">CompanyId</Name>
      <ValueType>
         <Type>xs:string</Type>
         <StringQualifiers>
            <Length>150</Length>
            <AllowedLength>Variable</AllowedLength>
         </StringQualifiers>
      </ValueType>
   </column>
   <column>
      <Name xsi:type="xs:string">OrderDate</Name>
      <ValueType>
         <Type>xs:dateTime</Type>
         <DateQualifiers>
            <DateFractions>DateTime</DateFractions>
         </DateQualifiers>
      </ValueType>
   </column>
   <column>
      <Name xsi:type="xs:string">OrderNumber</Name>
      <ValueType>
         <Type>xs:string</Type>
         <StringQualifiers>
            <Length>150</Length>
            <AllowedLength>Variable</AllowedLength>
         </StringQualifiers>
      </ValueType>
   </column>
   <row>
      <Value>2022-01-24T00:00:00</Value>
      <Value>10234</Value>
      <Value>10234</Value>
   </row>
   <row>
      <Value>2022-01-24T00:00:00</Value>
      <Value>52817</Value>
      <Value>52817</Value>
   </row>
   <row>
      <Value>2022-01-24T00:00:00</Value>
      <Value>58259</Value>
      <Value>58259</Value>
   </row>
   <row>
      <Value>2022-01-24T00:00:00</Value>
      <Value>WE30395.c17639</Value>
   </row>
   <row>
      <Value>2022-01-24T00:00:00</Value>
      <Value>WE30395.c17639</Value>
   </row>
   <row>
      <Value>2022-01-24T00:00:00</Value>
      <Value>WE30395.c17639</Value>
   </row>
</ValueTable>
</code>```

need

```<code><ValueTable xmlns="http://v8.1c.ru/8.1/data/core"
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <column>
      <Name xsi:type="xs:string">ActionDate</Name>
      <ValueType>
         <Type>xs:dateTime</Type>
         <DateQualifiers>
            <DateFractions>DateTime</DateFractions>
         </DateQualifiers>
      </ValueType>
   </column>
   <column>
      <Name xsi:type="xs:string">AddressId</Name>
      <ValueType>
         <Type>xs:string</Type>
         <StringQualifiers>
            <Length>150</Length>
            <AllowedLength>Variable</AllowedLength>
         </StringQualifiers>
      </ValueType>
   </column>
   <column>
      <Name xsi:type="xs:string">CompanyId</Name>
      <ValueType>
         <Type>xs:string</Type>
         <StringQualifiers>
            <Length>150</Length>
            <AllowedLength>Variable</AllowedLength>
         </StringQualifiers>
      </ValueType>
   </column>
   <column>
      <Name xsi:type="xs:string">OrderDate</Name>
      <ValueType>
         <Type>xs:dateTime</Type>
         <DateQualifiers>
            <DateFractions>DateTime</DateFractions>
         </DateQualifiers>
      </ValueType>
   </column>
   <column>
      <Name xsi:type="xs:string">OrderNumber</Name>
      <ValueType>
         <Type>xs:string</Type>
         <StringQualifiers>
            <Length>150</Length>
            <AllowedLength>Variable</AllowedLength>
         </StringQualifiers>
      </ValueType>
   </column>
   <row>
      <Value>2022-01-24T00:00:00</Value>
      <Value>10234</Value>
      <Value>10234</Value>
      <Value>2022-01-24T00:00:00</Value>
      <Value>WE30395.c17639</Value>
   </row>
   <row>
      <Value>2022-01-24T00:00:00</Value>
      <Value>52817</Value>
      <Value>52817</Value>
      <Value>2022-01-24T00:00:00</Value>
      <Value>WE30395.c17639</Value>
   </row>
   <row>
      <Value>2022-01-24T00:00:00</Value>
      <Value>58259</Value>
      <Value>58259</Value>
     <Value>2022-01-24T00:00:00</Value>
      <Value>WE30395.c17639</Value>
   </row>
 </ValueTable>
</code>```

Briefly, the structure can be described as follows

I mean this is how I got it

```<code><table>
  <header>
    <column1>
    <column2>
    <column3>
    <column4>
    <column5>
  <header>
<row>
   value1
   value2
   value3
</row>
<row>
   value4
   value5
</row>
</table>
</code>```

but it should be like this

```<code><table>
  <header>
   <column1>
   <column2>
   <column3>
   <column4>
   <column5>
  </header>
<row>
   value1
   value2
   value3
   value4
   value5
</row>
</table>
</code>```

答:
The example is rather confusing because many values are identical and it's hard to see what goes where. It's also not clear if there can be more data elements and if so, what should the result be then.

AFAICT, this produces the expected result for the given example. For clarity, I have omitted the header part, which seems to be working fine.

XSLT 1.0

```<code><xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="xml" indent="yes" />

<xsl:template match="/extdata/scheme">
    <ValueTable xmlns="http://v8.1c.ru/8.1/data/core" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <!-- header -->

        <!-- data -->
        <xsl:for-each select="data[1]/o/d/r">
            <row>
                <xsl:variable name="i" select="position()"/>
                <xsl:for-each select="//data/o/d/r[$i]/f">
                    <Value>
                        <xsl:value-of select="." />
                    </Value>
                </xsl:for-each>
            </row>
        </xsl:for-each>
    </ValueTable>
</xsl:template>

</xsl:stylesheet>
</code>```

Body:
I need help with merging several tables of one file into one output.
The files that I get processed perfectly according to the XSLT schema that is listed below. But today I received an interesting file that was not processed as I wanted.

source file

<?xml version="1.0" encoding="utf-8"?>
<extdata user="test">
  <scheme name="Order">
    <data>
      <s>
        <d name="CashOrder">
          <f name="ActionDate" type="Date" />
          <f name="AddressId" type="String" />
          <f name="CompanyId" type="String" />
        </d>
      </s>
      <o>
        <d name="CashOrder">
          <r>
            <f>2022-01-24T00:00:00</f>
            <f>10234</f>
            <f>10234</f>
          </r>
          <r>
            <f>2022-01-24T00:00:00</f>
            <f>52817</f>
            <f>52817</f>
          </r>
          <r>
            <f>2022-01-24T00:00:00</f>
            <f>58259</f>
            <f>58259</f>
          </r>
        </d>
      </o>
    </data>
    <data>
      <s>
        <d name="OrderOption">
          <f name="OrderDate" type="Date" />
          <f name="OrderNumber" type="String" />
        </d>
      </s>
      <o>
        <d name="OrderOption">
          <r>
            <f>2022-01-24T00:00:00</f>
            <f>WE30395.c17639</f>
          </r>
          <r>
            <f>2022-01-24T00:00:00</f>
            <f>WE30395.c17639</f>
          </r>
          <r>
            <f>2022-01-24T00:00:00</f>
            <f>WE30395.c17639</f>
          </r>
        </d>
      </o>
    </data>
  </scheme>
</extdata>

my XSLT (here they helped me with writing.there was a problem with the recursive processing of the hierarchy)

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
   <xsl:output method="xml" indent="yes" />
   <xsl:template match="/extdata/scheme">
      <ValueTable xmlns="http://v8.1c.ru/8.1/data/core" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <xsl:for-each select="data/s/d/f | data/s/d/d/f">
            <column>
               <Name xsi:type="xs:string">
                  <xsl:value-of select="@name" />
               </Name>
               <ValueType>
                  <xsl:if test="@type= 'String'">
                     <Type>xs:string</Type>
                     <StringQualifiers>
                        <Length>150</Length>
                        <AllowedLength>Variable</AllowedLength>
                     </StringQualifiers>
                  </xsl:if>
                  <xsl:if test="@type= 'Date'">
                     <Type>xs:dateTime</Type>
                     <DateQualifiers>
                        <DateFractions>DateTime</DateFractions>
                     </DateQualifiers>
                  </xsl:if>
                  <xsl:if test="@type= 'Decimal' or @type= 'Currency'">
                     <Type>xs:decimal</Type>
                     <NumberQualifiers>
                        <Digits>20</Digits>
                        <FractionDigits>4</FractionDigits>
                        <AllowedSign>Any</AllowedSign>
                     </NumberQualifiers>
                  </xsl:if>
                  <xsl:if test="@type= 'Integer'">
                     <Type>xs:decimal</Type>
                     <NumberQualifiers>
                        <Digits>20</Digits>
                        <FractionDigits>0</FractionDigits>
                        <AllowedSign>Any</AllowedSign>
                     </NumberQualifiers>
                  </xsl:if>
               </ValueType>
            </column>
         </xsl:for-each>
         <xsl:for-each select="data/o/d/r">
            <row>
               <xsl:for-each select=".//f">
                  <Value>
                     <xsl:value-of select="." />
                  </Value>
               </xsl:for-each>
            </row>
         </xsl:for-each>
      </ValueTable>
   </xsl:template>
</xsl:stylesheet>

output now

      <ValueTable xmlns="http://v8.1c.ru/8.1/data/core"
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <column>
      <Name xsi:type="xs:string">ActionDate</Name>
      <ValueType>
         <Type>xs:dateTime</Type>
         <DateQualifiers>
            <DateFractions>DateTime</DateFractions>
         </DateQualifiers>
      </ValueType>
   </column>
   <column>
      <Name xsi:type="xs:string">AddressId</Name>
      <ValueType>
         <Type>xs:string</Type>
         <StringQualifiers>
            <Length>150</Length>
            <AllowedLength>Variable</AllowedLength>
         </StringQualifiers>
      </ValueType>
   </column>
   <column>
      <Name xsi:type="xs:string">CompanyId</Name>
      <ValueType>
         <Type>xs:string</Type>
         <StringQualifiers>
            <Length>150</Length>
            <AllowedLength>Variable</AllowedLength>
         </StringQualifiers>
      </ValueType>
   </column>
   <column>
      <Name xsi:type="xs:string">OrderDate</Name>
      <ValueType>
         <Type>xs:dateTime</Type>
         <DateQualifiers>
            <DateFractions>DateTime</DateFractions>
         </DateQualifiers>
      </ValueType>
   </column>
   <column>
      <Name xsi:type="xs:string">OrderNumber</Name>
      <ValueType>
         <Type>xs:string</Type>
         <StringQualifiers>
            <Length>150</Length>
            <AllowedLength>Variable</AllowedLength>
         </StringQualifiers>
      </ValueType>
   </column>
   <row>
      <Value>2022-01-24T00:00:00</Value>
      <Value>10234</Value>
      <Value>10234</Value>
   </row>
   <row>
      <Value>2022-01-24T00:00:00</Value>
      <Value>52817</Value>
      <Value>52817</Value>
   </row>
   <row>
      <Value>2022-01-24T00:00:00</Value>
      <Value>58259</Value>
      <Value>58259</Value>
   </row>
   <row>
      <Value>2022-01-24T00:00:00</Value>
      <Value>WE30395.c17639</Value>
   </row>
   <row>
      <Value>2022-01-24T00:00:00</Value>
      <Value>WE30395.c17639</Value>
   </row>
   <row>
      <Value>2022-01-24T00:00:00</Value>
      <Value>WE30395.c17639</Value>
   </row>
</ValueTable>

need

<ValueTable xmlns="http://v8.1c.ru/8.1/data/core"
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <column>
      <Name xsi:type="xs:string">ActionDate</Name>
      <ValueType>
         <Type>xs:dateTime</Type>
         <DateQualifiers>
            <DateFractions>DateTime</DateFractions>
         </DateQualifiers>
      </ValueType>
   </column>
   <column>
      <Name xsi:type="xs:string">AddressId</Name>
      <ValueType>
         <Type>xs:string</Type>
         <StringQualifiers>
            <Length>150</Length>
            <AllowedLength>Variable</AllowedLength>
         </StringQualifiers>
      </ValueType>
   </column>
   <column>
      <Name xsi:type="xs:string">CompanyId</Name>
      <ValueType>
         <Type>xs:string</Type>
         <StringQualifiers>
            <Length>150</Length>
            <AllowedLength>Variable</AllowedLength>
         </StringQualifiers>
      </ValueType>
   </column>
   <column>
      <Name xsi:type="xs:string">OrderDate</Name>
      <ValueType>
         <Type>xs:dateTime</Type>
         <DateQualifiers>
            <DateFractions>DateTime</DateFractions>
         </DateQualifiers>
      </ValueType>
   </column>
   <column>
      <Name xsi:type="xs:string">OrderNumber</Name>
      <ValueType>
         <Type>xs:string</Type>
         <StringQualifiers>
            <Length>150</Length>
            <AllowedLength>Variable</AllowedLength>
         </StringQualifiers>
      </ValueType>
   </column>
   <row>
      <Value>2022-01-24T00:00:00</Value>
      <Value>10234</Value>
      <Value>10234</Value>
      <Value>2022-01-24T00:00:00</Value>
      <Value>WE30395.c17639</Value>
   </row>
   <row>
      <Value>2022-01-24T00:00:00</Value>
      <Value>52817</Value>
      <Value>52817</Value>
      <Value>2022-01-24T00:00:00</Value>
      <Value>WE30395.c17639</Value>
   </row>
   <row>
      <Value>2022-01-24T00:00:00</Value>
      <Value>58259</Value>
      <Value>58259</Value>
     <Value>2022-01-24T00:00:00</Value>
      <Value>WE30395.c17639</Value>
   </row>
 </ValueTable>

Briefly, the structure can be described as follows

I mean this is how I got it

    <column1>
    <column2>
    <column3>
    <column4>
    <column5>

<row>
   value1
   value2
   value3
</row>
<row>
   value4
   value5
</row>

but it should be like this

   <column1>
   <column2>
   <column3>
   <column4>
   <column5>

<row>
   value1
   value2
   value3
   value4
   value5
</row>

Body:
The example is rather confusing because many values are identical and it's hard to see what goes where. It's also not clear if there can be more data elements and if so, what should the result be then.

AFAICT, this produces the expected result for the given example. For clarity, I have omitted the header part, which seems to be working fine.

XSLT 1.0

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="xml" indent="yes" />

<xsl:template match="/extdata/scheme">
    <ValueTable xmlns="http://v8.1c.ru/8.1/data/core" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <!-- header -->

        <!-- data -->
        <xsl:for-each select="data[1]/o/d/r">
            <row>
                <xsl:variable name="i" select="position()"/>
                <xsl:for-each select="//data/o/d/r[$i]/f">
                    <Value>
                        <xsl:value-of select="." />
                    </Value>
                </xsl:for-each>
            </row>
        </xsl:for-each>
    </ValueTable>
</xsl:template>

</xsl:stylesheet>


来源: stackexchange

问:
Is for(1) always the same as do in perl?
```<code>for(1){
  print 1;
}

do {
  print 1;
}
</code>```

Is it true?

Or is there any special case these two doesn't equal?

答:
You might really be looking for just plain curlies.

```<code>{
   print 1;
}
</code>```

It has the following benefits:

Creates a lexical scope (like for (1) and do {}).

You can use next, last and redo in them (like for (1)).

It doesn't mask $_ (like do {}).

But

It can only used where a statement is expected (like for (1), but unlike do {}).

Therefore, { ... } makes more sense than for (1) { ... }, and do { ... } is useful when you want to return a value.

ContentLicense: CC BY-SA 3.0

Body:
for(1){
  print 1;
}

do {
  print 1;
}

Is it true?

Or is there any special case these two doesn't equal?

Body:
You might really be looking for just plain curlies.

{
   print 1;
}

It has the following benefits:

Creates a lexical scope (like for (1) and do {}).

You can use next, last and redo in them (like for (1)).

It doesn't mask $_ (like do {}).

But

It can only used where a statement is expected (like for (1), but unlike do {}).

Therefore, { ... } makes more sense than for (1) { ... }, and do { ... } is useful when you want to return a value.


问:
jq: reduce and map combination
Here my current jq script:

```<code>def reduce_generateId:
    .[] | (. + {generalPractitionerCode: (.UAB_UP + "-" + .UAB_COD_UAB)});

def reduce_generalPractitioner($practitionerRole):
    (reduce $practitionerRole[] as $g (
        {};
        .[$g.oid1 + "-" + $g.oid2].generalPractitioner += ($g | [.id])
    )) as $dict
    | $dict;

reduce_generateId | reduce_generalPractitioner($generalPractitioner)
</code>```

My jq command is:

```<code>jq -s -f merge-patient.jq --argfile generalPractitioner reduced_ids.json reduced_pacient.json
</code>```

Where reduced_pacient.json:

{ "UAB_UP": "00003", "UAB_COD_UAB": "3212", "INVENTAT": "02"}
{ "UAB_UP": "00006", "UAB_COD_UAB": "5881", "INVENTAT": "102"}
{ "UAB_UP": "00006", "UAB_COD_UAB": "5751", "INVENTAT": "102"}
```
<p>and <code>reduced_ids.json</code>:</p>
<pre class="lang-json prettyprint-override"><code>[
  {
    "id": "3e67b455-8cdb-4bc0-a5e1-f90253870fc9",
    "oid1": "04374",
    "oid2": "INFP3"
  },
  {
    "id": "0f22e5ff-70bc-457f-bdaf-7afe86d478de",
    "oid1": "04376",
    "oid2": "INF07"
  }
]
</code>```

As you can see, redux_generalPractitioner returns $dict straightforwardly. I'm getting this:

{
  "04374-INFP3": {
    "generalPractitioner": [
      "3e67b455-8cdb-4bc0-a5e1-f90253870fc9"
    ]
  },
  "04376-INF07": {
    "generalPractitioner": [
      "0f22e5ff-70bc-457f-bdaf-7afe86d478de"
    ]
  }
}
{
  "04374-INFP3": {
    "generalPractitioner": [
      "3e67b455-8cdb-4bc0-a5e1-f90253870fc9"
    ]
  },
  "04376-INF07": {
    "generalPractitioner": [
      "0f22e5ff-70bc-457f-bdaf-7afe86d478de"
    ]
  }
}
{
  "04374-INFP3": {
    "generalPractitioner": [
      "3e67b455-8cdb-4bc0-a5e1-f90253870fc9"
    ]
  },
  "04376-INF07": {
    "generalPractitioner": [
      "0f22e5ff-70bc-457f-bdaf-7afe86d478de"
    ]
  }
}
```
<p>As you can see, I'm getting <code>$dict</code> three times.</p>
<p>I don't quite figure out why it's generating three <code>$dict</code> instead of one.</p>
<p>If I only perform <code>reduce_generalPractitioner($generalPractitioner)</code>, I'm getting:</p>
<pre class="lang-json prettyprint-override"><code>{
  "04374-INFP3": {
    "generalPractitioner": [
      "3e67b455-8cdb-4bc0-a5e1-f90253870fc9"
    ]
  },
  "04376-INF07": {
    "generalPractitioner": [
      "0f22e5ff-70bc-457f-bdaf-7afe86d478de"
    ]
  }
}
</code>```

Any ideas?

答:
Your program input, reduced_pacient.json is a stream of three objects. As you have set the --slurp flag, the initial context of your script is an array of three elements.

First, you're calling reduce_generateId which by iteration .[] decomposes the array into its three items. Thus reduce_generateId has three outputs.

Next, these are fed by pipe into your reduce_generalPractitioner function which consequently is run three times. Each run produces your $dict once, yielding three times in total.

Remember: Although your function reduce_generalPractitioner has an input parameter, it also has (just like every filter in jq) a general input context (addressed through piping), which determines the value of . and subsequently the number of runs.

ContentLicense: CC BY-SA 4.0

Title: jq: reduce and map combination

Body:
Here my current jq script:

def reduce_generateId:
    .[] | (. + {generalPractitionerCode: (.UAB_UP + "-" + .UAB_COD_UAB)});

def reduce_generalPractitioner($practitionerRole):
    (reduce $practitionerRole[] as $g (
        {};
        .[$g.oid1 + "-" + $g.oid2].generalPractitioner += ($g | [.id])
    )) as $dict
    | $dict;

reduce_generateId | reduce_generalPractitioner($generalPractitioner)

My jq command is:

jq -s -f merge-patient.jq --argfile generalPractitioner reduced_ids.json reduced_pacient.json

Where reduced_pacient.json:

{ "UAB_UP": "00003", "UAB_COD_UAB": "3212", "INVENTAT": "02"}
{ "UAB_UP": "00006", "UAB_COD_UAB": "5881", "INVENTAT": "102"}
{ "UAB_UP": "00006", "UAB_COD_UAB": "5751", "INVENTAT": "102"}

and reduced_ids.json:

[
  {
    "id": "3e67b455-8cdb-4bc0-a5e1-f90253870fc9",
    "oid1": "04374",
    "oid2": "INFP3"
  },
  {
    "id": "0f22e5ff-70bc-457f-bdaf-7afe86d478de",
    "oid1": "04376",
    "oid2": "INF07"
  }
]

As you can see, redux_generalPractitioner returns $dict straightforwardly. I'm getting this:

{
  "04374-INFP3": {
    "generalPractitioner": [
      "3e67b455-8cdb-4bc0-a5e1-f90253870fc9"
    ]
  },
  "04376-INF07": {
    "generalPractitioner": [
      "0f22e5ff-70bc-457f-bdaf-7afe86d478de"
    ]
  }
}
{
  "04374-INFP3": {
    "generalPractitioner": [
      "3e67b455-8cdb-4bc0-a5e1-f90253870fc9"
    ]
  },
  "04376-INF07": {
    "generalPractitioner": [
      "0f22e5ff-70bc-457f-bdaf-7afe86d478de"
    ]
  }
}
{
  "04374-INFP3": {
    "generalPractitioner": [
      "3e67b455-8cdb-4bc0-a5e1-f90253870fc9"
    ]
  },
  "04376-INF07": {
    "generalPractitioner": [
      "0f22e5ff-70bc-457f-bdaf-7afe86d478de"
    ]
  }
}

As you can see, I'm getting $dict three times.

I don't quite figure out why it's generating three $dict instead of one.

If I only perform reduce_generalPractitioner($generalPractitioner), I'm getting:

{
  "04374-INFP3": {
    "generalPractitioner": [
      "3e67b455-8cdb-4bc0-a5e1-f90253870fc9"
    ]
  },
  "04376-INF07": {
    "generalPractitioner": [
      "0f22e5ff-70bc-457f-bdaf-7afe86d478de"
    ]
  }
}

Any ideas?


问:
MS Graph API - How to bring more than 100 lists from contracts endpoint?
https://learn.microsoft.com/en-us/graph/api/contract-list?view=graph-rest-1.0&tabs=http

I got a contract list through the contract endpoint, but I could only get up to 100 lists, and I couldn't get a list that exceeded them.

Is there any data that needs to be added when requesting api To bring more than 101 lists?
(Currently, our company has more than 150 contracts.)

答:
You can try to add $top query parameter to specify the page size of the result set.

The minimum value of $top is 1 and the maximum depends on the corresponding API.

```<code>GET https://graph.microsoft.com/v1.0/contracts?$top=500
</code>```

Otherwise, you will need to use @odata.nextLink property to get next 100 results.

Resources:

Top parameter

Paging

Body:
You can try to add $top query parameter to specify the page size of the result set.

The minimum value of $top is 1 and the maximum depends on the corresponding API.

GET https://graph.microsoft.com/v1.0/contracts?$top=500

Otherwise, you will need to use @odata.nextLink property to get next 100 results.

Resources:

Top parameter

Paging


问:
Segmentation fault in getaddrinfo()
I am getting segmentation fault in getaddrinfo().

This is the stack trace.

```<code>Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb7ff4b70 (LWP 26872)]
__res_vinit (statp=0xb7ff4df4, preinit=0) at res_init.c:176
176 res_init.c: No such file or directory.
    in res_init.c
(gdb) bt
#0  __res_vinit (statp=0xb7ff4df4, preinit=0) at res_init.c:176
#1  0x0042fe95 in *__GI___res_ninit (statp=0xb7ff4df4) at res_init.c:142
#2  0x00430ea0 in *__GI___res_maybe_init (resp=0xb7ff4df4, preinit=0) at res_libc.c:122
#3  0x003f86f4 in gaih_inet (name=<value optimized out>, service=<value optimized out>, req=0xb7ff3df8, pai=0xb7ff3db4, naddrs=0xb7ff3da4)
    at ../sysdeps/posix/getaddrinfo.c:690
#4  0x003faa65 in *__GI_getaddrinfo (name=0x8203a68 "api.shoutcast.com", service=0x810ae72 "http", hints=0xb7ff3df8, pai=0xb7ff3e24)
    at ../sysdeps/posix/getaddrinfo.c:2160
#5  0x08050a87 in test_addrinfo () at /kkkk/myaddrinfo.c:33
</code>```

The source of the function test_addrinfo();

```<code>    #ifndef   NI_MAXHOST
    #define   NI_MAXHOST 1025
    #endif

    struct  addrinfo hints =
    {
        .ai_flags       = 0,        /* Input flags.                 nothing special */
        .ai_family      = PF_UNSPEC,/* Protocol family for socket.  any  */
        .ai_socktype    = SOCK_STREAM,        /* Socket type.                 take any (SOCK_RAW, SOCK_STREAM,  SOCK_DGRAM) */
        .ai_protocol    = IPPROTO_TCP,        /* Protocol for socket.         take any (IPPROTO_TCP and IPPROTO_UDP) */
        .ai_addrlen     = 0,        /* Length of socket address.    always 0 */
        .ai_addr        = NULL,     /* Socket address for socket.   always NULL */
        .ai_canonname   = NULL,     /* Canonical name for service.  always NULL */
        .ai_next        = NULL,     /* Pointer to next in list.     always NULL */
    };

    int test_addrinfo(void)
    {
        struct addrinfo *result = NULL;
        struct addrinfo *res;
        int error;

        /* resolve the domain name into a list of addresses */
        error = getaddrinfo("api.shoutcast.com", "http", &hints, &result);
        if (error != 0)
        {
            fprintf(stderr, "error in getaddrinfo: %s\n", gai_strerror(error));
            return EXIT_FAILURE;
        }

        /* loop over all returned results and do inverse lookup */
        for (res = result; res != NULL; res = res->ai_next)
        {
            char hostname[NI_MAXHOST] = "";

            error = getnameinfo(res->ai_addr, res->ai_addrlen, hostname, NI_MAXHOST, NULL, 0, 0);
            if (error != 0)
            {
                fprintf(stderr, "error in getnameinfo: %s\n", gai_strerror(error));
                continue;
            }
            if (*hostname != '\0')
                printf("hostname: %s\n", hostname);
        }

        freeaddrinfo(result);
        return EXIT_SUCCESS;
    }
</code>```

After running in valgrind, I got the following log

```<code>    ==00:00:00:07.590 7788==
    ==00:00:00:07.590 7788== Process terminating with default action of signal 11 (SIGSEGV)
    ==00:00:00:07.590 7788==  Bad permissions for mapped region at address 0x4033BDC
    ==00:00:00:07.590 7788==    at 0x4348C8A: __res_vinit (res_init.c:176)
    ==00:00:00:07.645 7788==
</code>```

This function test_addrinfo() is called by a top layer in my application. I tested the same function in another application which has only one main(). It worked in that application.

I am suspecting that I am not using the correct gnulib library or wrong compilation flags. Any clues or hints?

答:
2022-02-08 16:55:33 , the same problem , I don't know how to solve it .

I knew , the error throw when call getaddrinfo()

My error info

```<code>(gdb) run
Starting program: /document/c_cpp_program/cpp_spider/main.out
test print 000
test print 111

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7cfe813 in __GI_getaddrinfo (name=<optimized out>, service=<optimized out>, hints=<optimized out>, pai=<optimized out>)
    at ../sysdeps/posix/getaddrinfo.c:2501
2501    ../sysdeps/posix/getaddrinfo.c: No such file or directory.
(gdb) bt
#0  0x00007ffff7cfe813 in __GI_getaddrinfo (name=<optimized out>, service=<optimized out>, hints=<optimized out>, pai=<optimized out>)
    at ../sysdeps/posix/getaddrinfo.c:2501
#1  0x0000555555555367 in test_socket_api () at main.cpp:29
#2  0x00005555555554c7 in main () at main.cpp:47
(gdb)
</code>```

My error code is

```<code>#include <iostream>
#include <sys/socket.h>
#include <stdio.h>
#include <netdb.h>
#include <string.h>
#include "net_opt/net_utils.h"
#include "example/other_test.h"

void test_socket_api() {
    std::string host_name = "www.google.com";
    std::string host_service = "80";
    struct addrinfo host_addr_info_limit ;
    struct addrinfo **host_addr_info_result;  //need fix ①

    std::cout << "test print 000 " << "\n" ;
    memset(&host_addr_info_limit, 0, sizeof(host_addr_info_limit));
    host_addr_info_limit = {
      .ai_flags = 0 ,
      .ai_family = AF_UNSPEC ,
      .ai_socktype = SOCK_STREAM ,
      .ai_protocol = 0 ,
      .ai_addrlen = 0 ,
      .ai_addr = NULL ,
      .ai_canonname = NULL ,
      .ai_next = NULL ,
    };
    std::cout << "test print 111" << "\n" ;

    int result_code = getaddrinfo(host_name.c_str(),
                                  host_service.c_str(),
                                  &host_addr_info_limit,
                                  host_addr_info_result);//need fix ②

    std::cout << "test print 222" << "\n" ;

    std::cout << "result_code = " << result_code << "\n";

    if (0 == result_code) {
        std::cout << "get data success ✅  \n";
    } else {
        std::cout << "get data failed ❌  ：" << gai_strerror(result_code) << "\n";
    }
}

int main() {
    test_socket_api();

    return 0;
}

</code>```

Edit 1 : Now I know how to solve problem , but i don't know why .

My refrence code:

man getaddrinfo

https://gist.github.com/jirihnidek/bf7a2363e480491da72301b228b35d5d

Segmentation fault in getaddrinfo()

base my code , I fix two point :

point one :

//struct addrinfo **host_addr_info_result;
//fix to --->
struct addrinfo *host_addr_info_result;
```
<p>point two :</p>
<pre class="lang-cpp prettyprint-override"><code>//int result_code = getaddrinfo(host_name.c_str(),
//                              host_service.c_str(),
//                              &host_addr_info_limit,
//                              host_addr_info_result);
// fix to -->
int result_code = getaddrinfo(host_name.c_str(),
                                  host_service.c_str(),
                                  &host_addr_info_limit,
                                  &host_addr_info_result);
</code>```

now my new question is : I don't know what's the different between the two spellings .

2022-02-09 11:58:00 ; I get other information , but i don't know how to explain the error .

the information is :

struct addrinfo **host_addr_info_result; make host_addr_info_result is NULL , the NULL param lead to getaddrinfo() run error .

struct addrinfo *host_addr_info_result; make host_addr_info_result is NULL , but &host_addr_info_result is not NULL , the unnull value make getaddrinfo() run success .

Edit 2 , I try to search file /sysdeps/posix/getaddrinfo.c and check method's implement that getAddrinfo() .

the code is : https://code.woboq.org/userspace/glibc/sysdeps/posix/getaddrinfo.c.html

```<code>//file path : https://code.woboq.org/userspace/glibc/sysdeps/posix/getaddrinfo.c.html

int
getaddrinfo (const char *name, const char *service,
             const struct addrinfo *hints, struct addrinfo **pai)
{
   .....//other code

   if (p)
    {
      *pai = p;    //this is crash point
                   //pai is NULL is that creash reason
      return 0;
    }

   .....//other code
}
</code>```

Now , my question is : my error msg content /sysdeps/posix/getaddrinfo.c: No such file or directory. ;
How can i find these codes on my computer?

Title: Segmentation fault in getaddrinfo()

Body:
I am getting segmentation fault in getaddrinfo().

This is the stack trace.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb7ff4b70 (LWP 26872)]
__res_vinit (statp=0xb7ff4df4, preinit=0) at res_init.c:176
176 res_init.c: No such file or directory.
    in res_init.c
(gdb) bt
#0  __res_vinit (statp=0xb7ff4df4, preinit=0) at res_init.c:176
#1  0x0042fe95 in *__GI___res_ninit (statp=0xb7ff4df4) at res_init.c:142
#2  0x00430ea0 in *__GI___res_maybe_init (resp=0xb7ff4df4, preinit=0) at res_libc.c:122
#3  0x003f86f4 in gaih_inet (name=<value optimized out>, service=<value optimized out>, req=0xb7ff3df8, pai=0xb7ff3db4, naddrs=0xb7ff3da4)
    at ../sysdeps/posix/getaddrinfo.c:690
#4  0x003faa65 in *__GI_getaddrinfo (name=0x8203a68 "api.shoutcast.com", service=0x810ae72 "http", hints=0xb7ff3df8, pai=0xb7ff3e24)
    at ../sysdeps/posix/getaddrinfo.c:2160
#5  0x08050a87 in test_addrinfo () at /kkkk/myaddrinfo.c:33

The source of the function test_addrinfo();

    #ifndef   NI_MAXHOST
    #define   NI_MAXHOST 1025
    #endif

    struct  addrinfo hints =
    {
        .ai_flags       = 0,        /* Input flags.                 nothing special */
        .ai_family      = PF_UNSPEC,/* Protocol family for socket.  any  */
        .ai_socktype    = SOCK_STREAM,        /* Socket type.                 take any (SOCK_RAW, SOCK_STREAM,  SOCK_DGRAM) */
        .ai_protocol    = IPPROTO_TCP,        /* Protocol for socket.         take any (IPPROTO_TCP and IPPROTO_UDP) */
        .ai_addrlen     = 0,        /* Length of socket address.    always 0 */
        .ai_addr        = NULL,     /* Socket address for socket.   always NULL */
        .ai_canonname   = NULL,     /* Canonical name for service.  always NULL */
        .ai_next        = NULL,     /* Pointer to next in list.     always NULL */
    };

    int test_addrinfo(void)
    {
        struct addrinfo *result = NULL;
        struct addrinfo *res;
        int error;

        /* resolve the domain name into a list of addresses */
        error = getaddrinfo("api.shoutcast.com", "http", &hints, &result);
        if (error != 0)
        {
            fprintf(stderr, "error in getaddrinfo: %s\n", gai_strerror(error));
            return EXIT_FAILURE;
        }

        /* loop over all returned results and do inverse lookup */
        for (res = result; res != NULL; res = res->ai_next)
        {
            char hostname[NI_MAXHOST] = "";

            error = getnameinfo(res->ai_addr, res->ai_addrlen, hostname, NI_MAXHOST, NULL, 0, 0);
            if (error != 0)
            {
                fprintf(stderr, "error in getnameinfo: %s\n", gai_strerror(error));
                continue;
            }
            if (*hostname != '\0')
                printf("hostname: %s\n", hostname);
        }

        freeaddrinfo(result);
        return EXIT_SUCCESS;
    }

After running in valgrind, I got the following log

    ==00:00:00:07.590 7788==
    ==00:00:00:07.590 7788== Process terminating with default action of signal 11 (SIGSEGV)
    ==00:00:00:07.590 7788==  Bad permissions for mapped region at address 0x4033BDC
    ==00:00:00:07.590 7788==    at 0x4348C8A: __res_vinit (res_init.c:176)
    ==00:00:00:07.645 7788==

This function test_addrinfo() is called by a top layer in my application. I tested the same function in another application which has only one main(). It worked in that application.

I am suspecting that I am not using the correct gnulib library or wrong compilation flags. Any clues or hints?

Body:
2022-02-08 16:55:33 , the same problem , I don't know how to solve it .

I knew , the error throw when call getaddrinfo()

My error info

(gdb) run
Starting program: /document/c_cpp_program/cpp_spider/main.out
test print 000
test print 111

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7cfe813 in __GI_getaddrinfo (name=<optimized out>, service=<optimized out>, hints=<optimized out>, pai=<optimized out>)
    at ../sysdeps/posix/getaddrinfo.c:2501
2501    ../sysdeps/posix/getaddrinfo.c: No such file or directory.
(gdb) bt
#0  0x00007ffff7cfe813 in __GI_getaddrinfo (name=<optimized out>, service=<optimized out>, hints=<optimized out>, pai=<optimized out>)
    at ../sysdeps/posix/getaddrinfo.c:2501
#1  0x0000555555555367 in test_socket_api () at main.cpp:29
#2  0x00005555555554c7 in main () at main.cpp:47
(gdb)

My error code is

#include <iostream>
#include <sys/socket.h>
#include <stdio.h>
#include <netdb.h>
#include <string.h>
#include "net_opt/net_utils.h"
#include "example/other_test.h"

void test_socket_api() {
    std::string host_name = "www.google.com";
    std::string host_service = "80";
    struct addrinfo host_addr_info_limit ;
    struct addrinfo **host_addr_info_result;  //need fix ①

    std::cout << "test print 000 " << "\n" ;
    memset(&host_addr_info_limit, 0, sizeof(host_addr_info_limit));
    host_addr_info_limit = {
      .ai_flags = 0 ,
      .ai_family = AF_UNSPEC ,
      .ai_socktype = SOCK_STREAM ,
      .ai_protocol = 0 ,
      .ai_addrlen = 0 ,
      .ai_addr = NULL ,
      .ai_canonname = NULL ,
      .ai_next = NULL ,
    };
    std::cout << "test print 111" << "\n" ;

    int result_code = getaddrinfo(host_name.c_str(),
                                  host_service.c_str(),
                                  &host_addr_info_limit,
                                  host_addr_info_result);//need fix ②

    std::cout << "test print 222" << "\n" ;

    std::cout << "result_code = " << result_code << "\n";

    if (0 == result_code) {
        std::cout << "get data success ✅  \n";
    } else {
        std::cout << "get data failed ❌  ：" << gai_strerror(result_code) << "\n";
    }
}

int main() {
    test_socket_api();

    return 0;
}

Edit 1 : Now I know how to solve problem , but i don't know why .

My refrence code:

man getaddrinfo

https://gist.github.com/jirihnidek/bf7a2363e480491da72301b228b35d5d

Segmentation fault in getaddrinfo()

base my code , I fix two point :

point one :

//struct addrinfo **host_addr_info_result;
//fix to --->
struct addrinfo *host_addr_info_result;

point two :

//int result_code = getaddrinfo(host_name.c_str(),
//                              host_service.c_str(),
//                              &host_addr_info_limit,
//                              host_addr_info_result);
// fix to -->
int result_code = getaddrinfo(host_name.c_str(),
                                  host_service.c_str(),
                                  &host_addr_info_limit,
                                  &host_addr_info_result);

now my new question is : I don't know what's the different between the two spellings .

2022-02-09 11:58:00 ; I get other information , but i don't know how to explain the error .

the information is :

struct addrinfo **host_addr_info_result; make host_addr_info_result is NULL , the NULL param lead to getaddrinfo() run error .

struct addrinfo *host_addr_info_result; make host_addr_info_result is NULL , but &host_addr_info_result is not NULL , the unnull value make getaddrinfo() run success .

Edit 2 , I try to search file /sysdeps/posix/getaddrinfo.c and check method's implement that getAddrinfo() .

the code is : https://code.woboq.org/userspace/glibc/sysdeps/posix/getaddrinfo.c.html

//file path : https://code.woboq.org/userspace/glibc/sysdeps/posix/getaddrinfo.c.html

int
getaddrinfo (const char *name, const char *service,
             const struct addrinfo *hints, struct addrinfo **pai)
{
   .....//other code

   if (p)
    {
      *pai = p;    //this is crash point
                   //pai is NULL is that creash reason
      return 0;
    }

   .....//other code
}

Now , my question is : my error msg content /sysdeps/posix/getaddrinfo.c: No such file or directory. ;
How can i find these codes on my computer?


问:
accentColor is deprecated and shouldn't be used
The accentColor in ThemeData was deprecated.

What to use then in ThemeData?

```<code>theme: ThemeData(
    brightness: Brightness.light,
    primaryColor: kBaseColor,
    accentColor: kBaseAccentColor, // 'accentColor' is deprecated and shouldn't be used
</code>```

答:
Code before migration:

Color myColor = Theme.of(context).accentColor;

Code after migration:

Color myColor = Theme.of(context).colorScheme.secondary;

Body:
The accentColor in ThemeData was deprecated.

What to use then in ThemeData?

theme: ThemeData(
    brightness: Brightness.light,
    primaryColor: kBaseColor,
    accentColor: kBaseAccentColor, // 'accentColor' is deprecated and shouldn't be used


问:
Java Regex not matching?
I have this code, but it does not seem to be working.

```<code>Pattern pattern=Pattern.compile("IMGURSESSION=([0-9a-zA-Z]*);");
Matcher matcher=pattern.matcher("IMGURSESSION=blahblah; path=/; domain=.imgur.com");
System.out.println(matcher.matches());
</code>```

Would anyone know why?

答:
the matches Method match against the entire input string.

if you will match only a subsequence you can use the find() method.

the 3 different ways to match with a matcher are explained in the java docs:
http://download.oracle.com/javase/7/docs/api/java/util/regex/Matcher.html

Title: Java Regex not matching?

Body:
I have this code, but it does not seem to be working.

Pattern pattern=Pattern.compile("IMGURSESSION=([0-9a-zA-Z]*);");
Matcher matcher=pattern.matcher("IMGURSESSION=blahblah; path=/; domain=.imgur.com");
System.out.println(matcher.matches());

Would anyone know why?


问:
Check if paragraph has value with jQuery
I want to check in the checkbox only those that have no value in the paragraph. I don't know where I made a mistake in the code, but when I click the button (Value > 0), it marks all the checkboxes. Where is the mistake?

$("input[id*='btnValue']").click(function() {
  var checked = !$(this).data('checked');
  if ($("p[id*='pCompanyValue']").val() == "") {
    $("input[id*='chkCustomer']").prop('checked', checked);
    $(this).data('checked', checked);
  }
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="modal-content" style="background-color:#f2f2f2;">
  <div class="modal-header">
    <h4 class="modal-title">Select customers:</h4>
    <table class="DataTable" border="0" cellpadding="2" cellspacing="0" width="100%">
      <tbody>
        <tr>
          <td class="CellNameButton"><input id="ctl06_repCustomers_ctl00_chkAllCustomers" type="checkbox" name="ctl06$repCustomers$ctl00$chkAllCustomers" onclick="javascript:setTimeout('__doPostBack(\'ctl06$repCustomers$ctl00$chkAllCustomers\',\'\')', 0)"></td>
          <td class="CellNameButton"><span id="ctl06_repCustomers_ctl00_Label7" class="CasualBold">Company name</span></td>
          <td class="CellNameButton"><span id="ctl06_repCustomers_ctl00_Label1" class="CasualBold">Value</span></td>
        </tr>
        <tr>
          <td>
            <input id="ctl06_repCustomers_ctl01_chkCustomer" type="checkbox" name="ctl06$repCustomers$ctl01$chkCustomer" onclick="javascript:setTimeout('__doPostBack(\'ctl06$repCustomers$ctl01$chkCustomer\',\'\')', 0)">
          </td>
          <td id="ctl06_repCustomers_ctl01_trCompanyName" class="CellValue" valign="center">
            <p id="ctl06_repCustomers_ctl01_pCompanyName" class="casual">random</p>
          </td>
          <td id="ctl06_repCustomers_ctl01_trCompanyValue" class="CellValue">
            <p id="ctl06_repCustomers_ctl01_pCompanyValue" class="casualRight">
              48.438,00</p>
          </td>

        </tr>

        <tr>
          <td>
            <input id="ctl06_repCustomers_ctl02_chkCustomer" type="checkbox" name="ctl06$repCustomers$ctl02$chkCustomer" onclick="javascript:setTimeout('__doPostBack(\'ctl06$repCustomers$ctl02$chkCustomer\',\'\')', 0)">

          </td>
          <td id="ctl06_repCustomers_ctl02_trCompanyName" class="CellValue" valign="center">
            <p id="ctl06_repCustomers_ctl02_pCompanyName" class="casual">random2</p>
          </td>

          <td id="ctl06_repCustomers_ctl02_trCompanyValue" class="CellValue">
            <p id="ctl06_repCustomers_ctl02_pCompanyValue" class="casualRight">
              0,00</p>
          </td>

        </tr>

        <tr>
          <td>
            <input id="ctl06_repCustomers_ctl03_chkCustomer" type="checkbox" name="ctl06$repCustomers$ctl03$chkCustomer" onclick="javascript:setTimeout('__doPostBack(\'ctl06$repCustomers$ctl03$chkCustomer\',\'\')', 0)">

          </td>
          <td id="ctl06_repCustomers_ctl03_trCompanyName" class="CellValue" valign="center" style="background-color:#fff0e0;">
            <p id="ctl06_repCustomers_ctl03_pCompanyName" class="casual">Random3</p>
          </td>
          <td id="ctl06_repCustomers_ctl03_trCompanyValue" class="CellValue" style="background-color:#fff0e0;">
            <p id="ctl06_repCustomers_ctl03_pCompanyValue" class="casualRight">
            </p>
          </td>
        </tr>
      </tbody>
    </table>

  </div>
  <div class="modal-footer">
    <table class="modal-body">
      <tbody>
        <tr>
          <td class="CellNameButton">
            <input type="submit" name="ctl06$btnValue" value="Value > 0" id="ctl06_btnValue">
          </td>

        </tr>
      </tbody>
    </table>
    <input type="submit" name="ctl06$btnConfirmCustomers" value="OK" id="ctl06_btnConfirmCustomers" class="CasualForm" check="true">
  </div>
</div></code>```

Unnecessary: This code is done in asp.net that's why it's generated like this with stupid id names.

答:
Here's what the code looks like now. I don't know why it won't work again.

$("input[id*='btnValue']").click(function() {
  $("p[id*='pCompanyValue']").each(function() {
    var checkId = $(this).attr("id").replace("pCompanyValue", "chkCustomer");
    if ($(this).text().trim().length > 0) {
      $("#" + checkId).attr("checked", true);
    }
  });
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="modal-content" style="background-color:#f2f2f2;">
  <div class="modal-header">
    <h4 class="modal-title">Select customers:</h4>
  </div>
  <div id="thisone" class="modal-body" style="max-height: calc(100vh - 210px); overflow-y: auto;">

    <table class="DataTable" border="0" cellpadding="2" cellspacing="0" width="100%">
      <tbody>
        <tr>
          <td class="CellNameButton"><input id="ctl06_repCustomers_ctl00_chkAllCustomers" type="checkbox" name="ctl06$repCustomers$ctl00$chkAllCustomers" onclick="javascript:setTimeout('__doPostBack(\'ctl06$repCustomers$ctl00$chkAllCustomers\',\'\')', 0)"></td>
          <td class="CellNameButton"><span id="ctl06_repCustomers_ctl00_Label7" class="CasualBold">Company name</span></td>
          <td class="CellNameButton"><span id="ctl06_repCustomers_ctl00_Label1" class="CasualBold">Value</span></td>
        </tr>

        <tr>
          <td>
            <input id="ctl06_repCustomers_ctl01_chkCustomer" type="checkbox" name="ctl06$repCustomers$ctl01$chkCustomer" onclick="javascript:setTimeout('__doPostBack(\'ctl06$repCustomers$ctl01$chkCustomer\',\'\')', 0)">

          </td>
          <td id="ctl06_repCustomers_ctl01_trCompanyName" class="CellValue" valign="center">
            <p id="ctl06_repCustomers_ctl01_pCompanyName" class="casual">RANDOM</p>
          </td>

          <td id="ctl06_repCustomers_ctl01_trCompanyValue" class="CellValue">
            <p id="ctl06_repCustomers_ctl01_pCompanyValue" class="casualRight">
              48.438,00</p>
          </td>

        </tr>

        <tr>
          <td>
            <input id="ctl06_repCustomers_ctl02_chkCustomer" type="checkbox" name="ctl06$repCustomers$ctl02$chkCustomer" onclick="javascript:setTimeout('__doPostBack(\'ctl06$repCustomers$ctl02$chkCustomer\',\'\')', 0)">

          </td>
          <td id="ctl06_repCustomers_ctl02_trCompanyName" class="CellValue" valign="center">
            <p id="ctl06_repCustomers_ctl02_pCompanyName" class="casual">RANDOM</p>
          </td>

          <td id="ctl06_repCustomers_ctl02_trCompanyValue" class="CellValue">
            <p id="ctl06_repCustomers_ctl02_pCompanyValue" class="casualRight">
              0,00</p>
          </td>

        </tr>

        <tr>
          <td>
            <input id="ctl06_repCustomers_ctl03_chkCustomer" type="checkbox" name="ctl06$repCustomers$ctl03$chkCustomer" onclick="javascript:setTimeout('__doPostBack(\'ctl06$repCustomers$ctl03$chkCustomer\',\'\')', 0)">

          </td>
          <td id="ctl06_repCustomers_ctl03_trCompanyName" class="CellValue" valign="center" style="background-color:#fff0e0;">
            <p id="ctl06_repCustomers_ctl03_pCompanyName" class="casual">RANDOM</p>
          </td>

          <td id="ctl06_repCustomers_ctl03_trCompanyValue" class="CellValue" style="background-color:#fff0e0;">
            <p id="ctl06_repCustomers_ctl03_pCompanyValue" class="casualRight">
            </p>
          </td>

        </tr>

        <tr>
          <td>
            <input id="ctl06_repCustomers_ctl04_chkCustomer" type="checkbox" name="ctl06$repCustomers$ctl04$chkCustomer" onclick="javascript:setTimeout('__doPostBack(\'ctl06$repCustomers$ctl04$chkCustomer\',\'\')', 0)">

          </td>
          <td id="ctl06_repCustomers_ctl04_trCompanyName" class="CellValue" valign="center" style="background-color:#fff0e0;">
            <p id="ctl06_repCustomers_ctl04_pCompanyName" class="casual">RANDOM</p>
          </td>

          <td id="ctl06_repCustomers_ctl04_trCompanyValue" class="CellValue" style="background-color:#fff0e0;">
            <p id="ctl06_repCustomers_ctl04_pCompanyValue" class="casualRight">
            </p>
          </td>

        </tr>

        <tr>
          <td>
            <input id="ctl06_repCustomers_ctl05_chkCustomer" type="checkbox" name="ctl06$repCustomers$ctl05$chkCustomer" onclick="javascript:setTimeout('__doPostBack(\'ctl06$repCustomers$ctl05$chkCustomer\',\'\')', 0)">

          </td>
          <td id="ctl06_repCustomers_ctl05_trCompanyName" class="CellValue" valign="center" style="background-color:#fff0e0;">
            <p id="ctl06_repCustomers_ctl05_pCompanyName" class="casual">RANDOM</p>
          </td>

          <td id="ctl06_repCustomers_ctl05_trCompanyValue" class="CellValue" style="background-color:#fff0e0;">
            <p id="ctl06_repCustomers_ctl05_pCompanyValue" class="casualRight">
            </p>
          </td>

        </tr>
      </tbody>
    </table>

  </div>
  <div class="modal-footer">
    <table class="modal-body">
      <tbody>
        <tr>
          <td class="CellNameButton">
            <input type="submit" name="ctl06$bntValue" value="Value > 0" id="ctl06_bntValue">
          </td>
        </tr>
      </tbody>
    </table>
    <input type="submit" name="ctl06$btnConfirmCustomers" value="OK" id="ctl06_btnConfirmCustomers" class="CasualForm" check="true">
  </div>
</div></code>```

EDIT I found a mistake. I went to Google and found a site that compared two Html codes and in the second I wrote bntButton instead of btnButton.

Body:
I want to check in the checkbox only those that have no value in the paragraph. I don't know where I made a mistake in the code, but when I click the button (Value > 0), it marks all the checkboxes. Where is the mistake?

$("input[id*='btnValue']").click(function() {
  var checked = !$(this).data('checked');
  if ($("p[id*='pCompanyValue']").val() == "") {
    $("input[id*='chkCustomer']").prop('checked', checked);
    $(this).data('checked', checked);
  }
});

Select customers:

          <input id="ctl06_repCustomers_ctl00_chkAllCustomers" type="checkbox" name="ctl06$repCustomers$ctl00$chkAllCustomers" onclick="javascript:setTimeout('__doPostBack(\'ctl06$repCustomers$ctl00$chkAllCustomers\',\'\')', 0)">
          Company name
          Value

            <input id="ctl06_repCustomers_ctl01_chkCustomer" type="checkbox" name="ctl06$repCustomers$ctl01$chkCustomer" onclick="javascript:setTimeout('__doPostBack(\'ctl06$repCustomers$ctl01$chkCustomer\',\'\')', 0)">

random

              48.438,00

            <input id="ctl06_repCustomers_ctl02_chkCustomer" type="checkbox" name="ctl06$repCustomers$ctl02$chkCustomer" onclick="javascript:setTimeout('__doPostBack(\'ctl06$repCustomers$ctl02$chkCustomer\',\'\')', 0)">

random2

              0,00

            <input id="ctl06_repCustomers_ctl03_chkCustomer" type="checkbox" name="ctl06$repCustomers$ctl03$chkCustomer" onclick="javascript:setTimeout('__doPostBack(\'ctl06$repCustomers$ctl03$chkCustomer\',\'\')', 0)">

Random3

            <input type="submit" name="ctl06$btnValue" value="Value > 0" id="ctl06_btnValue">

    <input type="submit" name="ctl06$btnConfirmCustomers" value="OK" id="ctl06_btnConfirmCustomers" class="CasualForm" check="true">

Unnecessary: This code is done in asp.net that's why it's generated like this with stupid id names.

Body:
Here's what the code looks like now. I don't know why it won't work again.

$("input[id*='btnValue']").click(function() {
  $("p[id*='pCompanyValue']").each(function() {
    var checkId = $(this).attr("id").replace("pCompanyValue", "chkCustomer");
    if ($(this).text().trim().length > 0) {
      $("#" + checkId).attr("checked", true);
    }
  });
});

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="modal-content" style="background-color:#f2f2f2;">
  <div class="modal-header">
    <h4 class="modal-title">Select customers:</h4>
  </div>
  <div id="thisone" class="modal-body" style="max-height: calc(100vh - 210px); overflow-y: auto;">

    <table class="DataTable" border="0" cellpadding="2" cellspacing="0" width="100%">
      <tbody>
        <tr>
          <td class="CellNameButton"><input id="ctl06_repCustomers_ctl00_chkAllCustomers" type="checkbox" name="ctl06$repCustomers$ctl00$chkAllCustomers" onclick="javascript:setTimeout('__doPostBack(\'ctl06$repCustomers$ctl00$chkAllCustomers\',\'\')', 0)"></td>
          <td class="CellNameButton"><span id="ctl06_repCustomers_ctl00_Label7" class="CasualBold">Company name</span></td>
          <td class="CellNameButton"><span id="ctl06_repCustomers_ctl00_Label1" class="CasualBold">Value</span></td>
        </tr>

        <tr>
          <td>
            <input id="ctl06_repCustomers_ctl01_chkCustomer" type="checkbox" name="ctl06$repCustomers$ctl01$chkCustomer" onclick="javascript:setTimeout('__doPostBack(\'ctl06$repCustomers$ctl01$chkCustomer\',\'\')', 0)">

          </td>
          <td id="ctl06_repCustomers_ctl01_trCompanyName" class="CellValue" valign="center">
            <p id="ctl06_repCustomers_ctl01_pCompanyName" class="casual">RANDOM</p>
          </td>

          <td id="ctl06_repCustomers_ctl01_trCompanyValue" class="CellValue">
            <p id="ctl06_repCustomers_ctl01_pCompanyValue" class="casualRight">
              48.438,00</p>
          </td>

        </tr>

        <tr>
          <td>
            <input id="ctl06_repCustomers_ctl02_chkCustomer" type="checkbox" name="ctl06$repCustomers$ctl02$chkCustomer" onclick="javascript:setTimeout('__doPostBack(\'ctl06$repCustomers$ctl02$chkCustomer\',\'\')', 0)">

          </td>
          <td id="ctl06_repCustomers_ctl02_trCompanyName" class="CellValue" valign="center">
            <p id="ctl06_repCustomers_ctl02_pCompanyName" class="casual">RANDOM</p>
          </td>

          <td id="ctl06_repCustomers_ctl02_trCompanyValue" class="CellValue">
            <p id="ctl06_repCustomers_ctl02_pCompanyValue" class="casualRight">
              0,00</p>
          </td>

        </tr>

        <tr>
          <td>
            <input id="ctl06_repCustomers_ctl03_chkCustomer" type="checkbox" name="ctl06$repCustomers$ctl03$chkCustomer" onclick="javascript:setTimeout('__doPostBack(\'ctl06$repCustomers$ctl03$chkCustomer\',\'\')', 0)">

          </td>
          <td id="ctl06_repCustomers_ctl03_trCompanyName" class="CellValue" valign="center" style="background-color:#fff0e0;">
            <p id="ctl06_repCustomers_ctl03_pCompanyName" class="casual">RANDOM</p>
          </td>

          <td id="ctl06_repCustomers_ctl03_trCompanyValue" class="CellValue" style="background-color:#fff0e0;">
            <p id="ctl06_repCustomers_ctl03_pCompanyValue" class="casualRight">
            </p>
          </td>

        </tr>

        <tr>
          <td>
            <input id="ctl06_repCustomers_ctl04_chkCustomer" type="checkbox" name="ctl06$repCustomers$ctl04$chkCustomer" onclick="javascript:setTimeout('__doPostBack(\'ctl06$repCustomers$ctl04$chkCustomer\',\'\')', 0)">

          </td>
          <td id="ctl06_repCustomers_ctl04_trCompanyName" class="CellValue" valign="center" style="background-color:#fff0e0;">
            <p id="ctl06_repCustomers_ctl04_pCompanyName" class="casual">RANDOM</p>
          </td>

          <td id="ctl06_repCustomers_ctl04_trCompanyValue" class="CellValue" style="background-color:#fff0e0;">
            <p id="ctl06_repCustomers_ctl04_pCompanyValue" class="casualRight">
            </p>
          </td>

        </tr>

        <tr>
          <td>
            <input id="ctl06_repCustomers_ctl05_chkCustomer" type="checkbox" name="ctl06$repCustomers$ctl05$chkCustomer" onclick="javascript:setTimeout('__doPostBack(\'ctl06$repCustomers$ctl05$chkCustomer\',\'\')', 0)">

          </td>
          <td id="ctl06_repCustomers_ctl05_trCompanyName" class="CellValue" valign="center" style="background-color:#fff0e0;">
            <p id="ctl06_repCustomers_ctl05_pCompanyName" class="casual">RANDOM</p>
          </td>

          <td id="ctl06_repCustomers_ctl05_trCompanyValue" class="CellValue" style="background-color:#fff0e0;">
            <p id="ctl06_repCustomers_ctl05_pCompanyValue" class="casualRight">
            </p>
          </td>

        </tr>
      </tbody>
    </table>

  </div>
  <div class="modal-footer">
    <table class="modal-body">
      <tbody>
        <tr>
          <td class="CellNameButton">
            <input type="submit" name="ctl06$bntValue" value="Value > 0" id="ctl06_bntValue">
          </td>
        </tr>
      </tbody>
    </table>
    <input type="submit" name="ctl06$btnConfirmCustomers" value="OK" id="ctl06_btnConfirmCustomers" class="CasualForm" check="true">
  </div>
</div>

EDIT I found a mistake. I went to Google and found a site that compared two Html codes and in the second I wrote bntButton instead of btnButton.


问:
Changing directories in Cloud Build 'cd' no found
I'm using cloud build to clone a repository. I can confirm the repository clones successfully to the cloud build /workspace volume.

steps:
  - id: 'Clone repository'
    name: 'gcr.io/cloud-builders/git'
    args: ['clone', $_REPO_URL]
    volumes:
    - name: 'ssh'
      path: /root/.ssh
```
<p>I then run the next step to confirm</p>
<pre class="lang-yaml prettyprint-override"><code>  - id: 'List'
    name: 'alpine'
    args: ['ls']
</code>```

and it shows me the repository is in the current directory. But when I try and cd into the directory the cd command doesn't work and throws an error:

```<code>ERROR: build step 3 "alpine" failed: starting step container failed: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "cd <repo-name>": executable file not found in $PATH: unknown
</code>```

My ultimate goal is to cd into the repository and run some git commands. I use alpine later on because the git builder image doesn't allow me to use cd either.

substitutions:
  _REPO_NAME: 'test-repo'
  _REPO_URL: 'git@bitbucket.org:example/test-repo.git'
  _BRANCH_NAME: 'feature/something'

steps:
  - id: 'Clone repository'
    name: 'gcr.io/cloud-builders/git'
    args: ['clone', $_REPO_URL]
    volumes:
    - name: 'ssh'
      path: /root/.ssh

  - id: 'Check Diff'
    name: 'alpine'
    args: ['cd $_REPO_NAME', '&&', 'git checkout $_BRANCH_NAME', '&&', 'git diff main --name-only']
```

答:
Use dir field in your *.yaml file.

```<code>steps:
- name: string
  args: [string, string, ...]
  env: [string, string, ...]
  dir: string
  id: string
  waitFor: [string, string, ...]
  entrypoint: string
  secretEnv: string
  volumes: object(Volume)
  timeout: string (Duration format)
- name: string
  ...
- name: string
  ...
timeout: string (Duration format)
queueTtl: string (Duration format)
logsBucket: string
options:
 env: [string, string, ...]
 secretEnv: string
 volumes: object(Volume)
 sourceProvenanceHash: enum(HashType)
 machineType: enum(MachineType)
 diskSizeGb: string (int64 format)
 substitutionOption: enum(SubstitutionOption)
 dynamicSubstitutions: boolean
 logStreamingOption: enum(LogStreamingOption)
 logging: enum(LoggingMode)
 pool: object(PoolOption)
substitutions: map (key: string, value: string)
tags: [string, string, ...]
serviceAccount: string
secrets: object(Secret)
availableSecrets: object(Secrets)
artifacts: object (Artifacts)
images:
- [string, string, ...]
</code>```

https://cloud.google.com/build/docs/build-config-file-schema

Body:
I'm using cloud build to clone a repository. I can confirm the repository clones successfully to the cloud build /workspace volume.

steps:
  - id: 'Clone repository'
    name: 'gcr.io/cloud-builders/git'
    args: ['clone', $_REPO_URL]
    volumes:
    - name: 'ssh'
      path: /root/.ssh

I then run the next step to confirm

  - id: 'List'
    name: 'alpine'
    args: ['ls']

and it shows me the repository is in the current directory. But when I try and cd into the directory the cd command doesn't work and throws an error:

ERROR: build step 3 "alpine" failed: starting step container failed: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "cd <repo-name>": executable file not found in $PATH: unknown

My ultimate goal is to cd into the repository and run some git commands. I use alpine later on because the git builder image doesn't allow me to use cd either.

substitutions:
  _REPO_NAME: 'test-repo'
  _REPO_URL: 'git@bitbucket.org:example/test-repo.git'
  _BRANCH_NAME: 'feature/something'

steps:
  - id: 'Clone repository'
    name: 'gcr.io/cloud-builders/git'
    args: ['clone', $_REPO_URL]
    volumes:
    - name: 'ssh'
      path: /root/.ssh

  - id: 'Check Diff'
    name: 'alpine'
    args: ['cd $_REPO_NAME', '&&', 'git checkout $_BRANCH_NAME', '&&', 'git diff main --name-only']

Body:
Use dir field in your *.yaml file.

steps:
- name: string
  args: [string, string, ...]
  env: [string, string, ...]
  dir: string
  id: string
  waitFor: [string, string, ...]
  entrypoint: string
  secretEnv: string
  volumes: object(Volume)
  timeout: string (Duration format)
- name: string
  ...
- name: string
  ...
timeout: string (Duration format)
queueTtl: string (Duration format)
logsBucket: string
options:
 env: [string, string, ...]
 secretEnv: string
 volumes: object(Volume)
 sourceProvenanceHash: enum(HashType)
 machineType: enum(MachineType)
 diskSizeGb: string (int64 format)
 substitutionOption: enum(SubstitutionOption)
 dynamicSubstitutions: boolean
 logStreamingOption: enum(LogStreamingOption)
 logging: enum(LoggingMode)
 pool: object(PoolOption)
substitutions: map (key: string, value: string)
tags: [string, string, ...]
serviceAccount: string
secrets: object(Secret)
availableSecrets: object(Secrets)
artifacts: object (Artifacts)
images:
- [string, string, ...]

https://cloud.google.com/build/docs/build-config-file-schema


问:
Below are my c# codes i get system error message

This is my codes
using visual studio 2015
But when I am trying add role value i get the system error message "System.FormatException: 'Input string was not in a correct format"

```<code>        CDMSSEntities db;

        private void frmUser_Load(object sender, EventArgs e)
        {
            db = new CDMSSEntities();
            roleBindingSource.DataSource = db.Roles.ToList();
            userBindingSource.DataSource = db.Users.ToList();
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            User user = new User();
            userBindingSource.Add(user);
            userBindingSource.MoveLast();
            db.Users.Add(user);
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure to delete record?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                db.Users.Remove(userBindingSource.Current as User);
                userBindingSource.RemoveCurrent();
            }
        }

        private async void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                userBindingSource.EndEdit();
                await db.SaveChangesAsync();
                dataGridView.Refresh();
                MessageBox.Show("data saved.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}
</code>```

答:
Basically you're putting an "Admin" which is a String into a field that accepts only Int-32 values. Can you show us your database design?

You probably want to put 1,2,3 or whatever ID your "Admin" role has, instead of actually typing "Admin".

Body:
This is my codes
using visual studio 2015
But when I am trying add role value i get the system error message "System.FormatException: 'Input string was not in a correct format"

        CDMSSEntities db;

        private void frmUser_Load(object sender, EventArgs e)
        {
            db = new CDMSSEntities();
            roleBindingSource.DataSource = db.Roles.ToList();
            userBindingSource.DataSource = db.Users.ToList();
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            User user = new User();
            userBindingSource.Add(user);
            userBindingSource.MoveLast();
            db.Users.Add(user);
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure to delete record?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                db.Users.Remove(userBindingSource.Current as User);
                userBindingSource.RemoveCurrent();
            }
        }

        private async void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                userBindingSource.EndEdit();
                await db.SaveChangesAsync();
                dataGridView.Refresh();
                MessageBox.Show("data saved.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}


问:
array in array filter - javascript
hello i need help with array , as you can see my data

```<code>{
"age" : "18",
"altKategoriler" : [ "Dramalar" ],
"category" : [ "Aksiyon", "Heyecanlı", "Gerilim" ],
"id" : 5240718100,
"img" : "https://i.ibb.co/k8wx5C8/AAAABW9-ZJQOg-MRljz-Zwe30-JZw-Hf4vq-ERHq6-HMva5-ODHln-Ci-OEV6ir-Rcjt88tcnm-QGQCKpr-K9h-Oll-Ln-Sbb-EI.jpg",
"izlenilmeSayisi" : 0,
"logo" : "https://i.ibb.co/Rb2SrcB/AAAABfcrhh-Rni-Ok-Ct2l-Rys-ZYk-Oi-T0-XTeagkrw-Mkm-U0h-Lr-WIQZHEHg-VXihf-OWCwz-Vv-Qd7u-Ffn-DFZEX2-Ob.webp",
"oyuncuKadrosu" : [ "Diego Luna", "Michael Pena", "Scoot McNairy", "Tenoch Huerta", "Joaquin Cosio" ],
"senarist" : [ "Doug Miro" ],
"time" : "3 Sezon",
"title" : "Narcos: Mexico",
"type" : "Dizi",
"videoDescription" : "Guadalajara Karteli'nin yükselişinin gerçek öyküsünü anlatan bu yeni ve cesur Narcos hikâyesinde, Meksika'daki uyuşturucu savaşının 1980'lerdeki doğuşuna tanıklık edin.",
"videoQuality" : "HD",
"videosrc" : "https://tr.vid.web.acsta.net/uk/medias/nmedia/90/18/10/18/19/19550785_hd_013.mp4",
"year" : "2021",
"yonetmen" : [ "Carlo Bernard", "Chris Brancato" ]
}
</code>```

I can access elements such as id , title or logo because they are not arrays.

How can I loop through the data inside the array since there is an array in the category in yield?

```<code>var data = this.database.filter((item) => item.type == searchType)

var data = this.database.filter((item) => item.category == searchCategory)
</code>```

It's okay because my type value doesn't have an array.

But when I enter my category value, it only gets the first index[0]. It does not look at other indexes.

in summary,
item.category[0] , item.category[1] , item.category[2]...........

How can I get index browsing like

答:
You could make this a bit generic, by testing whether the targeted field is an array, using Array.isArray, and then call a filter on each element, and see if any is positive (using .some()). The filter can be function that is provided, so that it can perform a simple match, or apply a regular expression, or anything else.

Instead of testing with Array.isArray you could skip that step and check whether the value has a .some() method. If so, calling it will give the desired outcome, and otherwise (using the .? and ?? operators), the filter should be applied to the value as a whole:

Here is how that looks:

function applyFilter(data, field, filter) {
    return data.filter(item => item[field]?.some(filter) ?? filter(item));
}

// Example use:
var data = [{
  "category" : [ "Action", "Thriller", "Horror"],
  "type" : "Series",
}, {
  "category" : [ "Historical", "Romance" ],
  "type" : "Theatre",
}];

// Find entries that have a category that looks like "roman*":
var result = applyFilter(data, "category", value => /^roman.*/i.test(value));

console.log(result);```
</div>
</div>
</p>
<p>If you are running on an older version of JavaScript, and don't have support for <code>.?</code> or <code>??</code>, then use:</p>
```return data.filter(item => Array.isArray(item[field])
                         ? item[field].some(filter)
                         : filter(item));
```

Title: array in array filter - javascript

Body:
hello i need help with array , as you can see my data

{
"age" : "18",
"altKategoriler" : [ "Dramalar" ],
"category" : [ "Aksiyon", "Heyecanlı", "Gerilim" ],
"id" : 5240718100,
"img" : "https://i.ibb.co/k8wx5C8/AAAABW9-ZJQOg-MRljz-Zwe30-JZw-Hf4vq-ERHq6-HMva5-ODHln-Ci-OEV6ir-Rcjt88tcnm-QGQCKpr-K9h-Oll-Ln-Sbb-EI.jpg",
"izlenilmeSayisi" : 0,
"logo" : "https://i.ibb.co/Rb2SrcB/AAAABfcrhh-Rni-Ok-Ct2l-Rys-ZYk-Oi-T0-XTeagkrw-Mkm-U0h-Lr-WIQZHEHg-VXihf-OWCwz-Vv-Qd7u-Ffn-DFZEX2-Ob.webp",
"oyuncuKadrosu" : [ "Diego Luna", "Michael Pena", "Scoot McNairy", "Tenoch Huerta", "Joaquin Cosio" ],
"senarist" : [ "Doug Miro" ],
"time" : "3 Sezon",
"title" : "Narcos: Mexico",
"type" : "Dizi",
"videoDescription" : "Guadalajara Karteli'nin yükselişinin gerçek öyküsünü anlatan bu yeni ve cesur Narcos hikâyesinde, Meksika'daki uyuşturucu savaşının 1980'lerdeki doğuşuna tanıklık edin.",
"videoQuality" : "HD",
"videosrc" : "https://tr.vid.web.acsta.net/uk/medias/nmedia/90/18/10/18/19/19550785_hd_013.mp4",
"year" : "2021",
"yonetmen" : [ "Carlo Bernard", "Chris Brancato" ]
}

I can access elements such as id , title or logo because they are not arrays.

How can I loop through the data inside the array since there is an array in the category in yield?

var data = this.database.filter((item) => item.type == searchType)

var data = this.database.filter((item) => item.category == searchCategory)

It's okay because my type value doesn't have an array.

But when I enter my category value, it only gets the first index[0]. It does not look at other indexes.

in summary,
item.category[0] , item.category[1] , item.category[2]...........

How can I get index browsing like

Body:
You could make this a bit generic, by testing whether the targeted field is an array, using Array.isArray, and then call a filter on each element, and see if any is positive (using .some()). The filter can be function that is provided, so that it can perform a simple match, or apply a regular expression, or anything else.

Instead of testing with Array.isArray you could skip that step and check whether the value has a .some() method. If so, calling it will give the desired outcome, and otherwise (using the .? and ?? operators), the filter should be applied to the value as a whole:

Here is how that looks:

function applyFilter(data, field, filter) {
    return data.filter(item => item[field]?.some(filter) ?? filter(item));
}

// Example use:
var data = [{
  "category" : [ "Action", "Thriller", "Horror"],
  "type" : "Series",
}, {
  "category" : [ "Historical", "Romance" ],
  "type" : "Theatre",
}];

// Find entries that have a category that looks like "roman*":
var result = applyFilter(data, "category", value => /^roman.*/i.test(value));

console.log(result);

If you are running on an older version of JavaScript, and don't have support for .? or ??, then use:

return data.filter(item => Array.isArray(item[field])
                         ? item[field].some(filter)
                         : filter(item));


问:
Kernel error: ipykernel NotImplementedError

Error Message

```<code>Traceback (most recent call last):
  File "G:\anaconda\envs\jup\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "G:\anaconda\envs\jup\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\sk_np\AppData\Roaming\Python\Python38\site-packages\ipykernel_launcher.py", line 16, in <module>
    app.launch_new_instance()
  File "G:\anaconda\envs\jup\lib\site-packages\traitlets\config\application.py", line 844, in launch_instance
    app.initialize(argv)
  File "G:\anaconda\envs\jup\lib\site-packages\traitlets\config\application.py", line 87, in inner
    return method(app, *args, **kwargs)
  File "C:\Users\sk_np\AppData\Roaming\Python\Python38\site-packages\ipykernel\kernelapp.py", line 448, in initialize    self.init_sockets()
  File "C:\Users\sk_np\AppData\Roaming\Python\Python38\site-packages\ipykernel\kernelapp.py", line 251, in init_sockets
    self.init_iopub(context)
  File "C:\Users\sk_np\AppData\Roaming\Python\Python38\site-packages\ipykernel\kernelapp.py", line 259, in init_iopub    self.iopub_thread = IOPubThread(self.iopub_socket, pipe=True)
  File "C:\Users\sk_np\AppData\Roaming\Python\Python38\site-packages\ipykernel\iostream.py", line 63, in __init__
    self._setup_pipe_in()
  File "C:\Users\sk_np\AppData\Roaming\Python\Python38\site-packages\ipykernel\iostream.py", line 126, in _setup_pipe_in
    self._pipe_in = ZMQStream(pipe_in, self.io_loop)
  File "G:\anaconda\envs\jup\lib\site-packages\zmq\eventloop\zmqstream.py", line 127, in __init__
    self._init_io_state()
  File "G:\anaconda\envs\jup\lib\site-packages\zmq\eventloop\zmqstream.py", line 552, in _init_io_state
    self.io_loop.add_handler(self.socket, self._handle_events, self.io_loop.READ)
  File "G:\anaconda\envs\jup\lib\site-packages\tornado\platform\asyncio.py", line 100, in add_handler
    self.asyncio_loop.add_reader(fd, self._handle_events, fd, IOLoop.READ)
  File "G:\anaconda\envs\jup\lib\asyncio\events.py", line 501, in add_reader
    raise NotImplementedError
NotImplementedError

</code>```

Conda Environment Info:

jupyter-client:7.1.2

jupyter_client:5.3.1

python:3.8.0

I tried This Github Issue and followed the steps of This stackoverflow post.

Reproduction steps:

Install anaconda3

create conda env with conda create -n env python=3.8

conda install -c anaconda jupyter

jupyter notebook

答:
You have apparently anaconda installed, but also a seperate python installation, see how both C:\Users\sk_np\AppData\Roaming\Python\Python38 and G:\anaconda show up in your traceback. This is probably causing the issue due to inconsistencies in the packages. The simplest step, and the one that will save you a lot of headache in the future, would be to uninstall the python that you have at

```<code>C:\Users\sk_np\AppData\Roaming\Python\Python38
</code>```

Additionally, run in your anaconda prompt (from which you tried to start jupyter)

```<code>jupyter kernelspec list
</code>```

and then remove the kernel that is at C:\Users\sk_np\AppData\Roaming\Python\Python38 with

```<code>jupyter kernelspec remove <kernelName>
</code>```

Body:
Error Message

Traceback (most recent call last):
  File "G:\anaconda\envs\jup\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "G:\anaconda\envs\jup\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\sk_np\AppData\Roaming\Python\Python38\site-packages\ipykernel_launcher.py", line 16, in <module>
    app.launch_new_instance()
  File "G:\anaconda\envs\jup\lib\site-packages\traitlets\config\application.py", line 844, in launch_instance
    app.initialize(argv)
  File "G:\anaconda\envs\jup\lib\site-packages\traitlets\config\application.py", line 87, in inner
    return method(app, *args, **kwargs)
  File "C:\Users\sk_np\AppData\Roaming\Python\Python38\site-packages\ipykernel\kernelapp.py", line 448, in initialize    self.init_sockets()
  File "C:\Users\sk_np\AppData\Roaming\Python\Python38\site-packages\ipykernel\kernelapp.py", line 251, in init_sockets
    self.init_iopub(context)
  File "C:\Users\sk_np\AppData\Roaming\Python\Python38\site-packages\ipykernel\kernelapp.py", line 259, in init_iopub    self.iopub_thread = IOPubThread(self.iopub_socket, pipe=True)
  File "C:\Users\sk_np\AppData\Roaming\Python\Python38\site-packages\ipykernel\iostream.py", line 63, in __init__
    self._setup_pipe_in()
  File "C:\Users\sk_np\AppData\Roaming\Python\Python38\site-packages\ipykernel\iostream.py", line 126, in _setup_pipe_in
    self._pipe_in = ZMQStream(pipe_in, self.io_loop)
  File "G:\anaconda\envs\jup\lib\site-packages\zmq\eventloop\zmqstream.py", line 127, in __init__
    self._init_io_state()
  File "G:\anaconda\envs\jup\lib\site-packages\zmq\eventloop\zmqstream.py", line 552, in _init_io_state
    self.io_loop.add_handler(self.socket, self._handle_events, self.io_loop.READ)
  File "G:\anaconda\envs\jup\lib\site-packages\tornado\platform\asyncio.py", line 100, in add_handler
    self.asyncio_loop.add_reader(fd, self._handle_events, fd, IOLoop.READ)
  File "G:\anaconda\envs\jup\lib\asyncio\events.py", line 501, in add_reader
    raise NotImplementedError
NotImplementedError

Conda Environment Info:

jupyter-client:7.1.2

jupyter_client:5.3.1

python:3.8.0

I tried This Github Issue and followed the steps of This stackoverflow post.

Reproduction steps:

Install anaconda3

create conda env with conda create -n env python=3.8

conda install -c anaconda jupyter

jupyter notebook

Body:
You have apparently anaconda installed, but also a seperate python installation, see how both C:\Users\sk_np\AppData\Roaming\Python\Python38 and G:\anaconda show up in your traceback. This is probably causing the issue due to inconsistencies in the packages. The simplest step, and the one that will save you a lot of headache in the future, would be to uninstall the python that you have at

C:\Users\sk_np\AppData\Roaming\Python\Python38

Additionally, run in your anaconda prompt (from which you tried to start jupyter)

jupyter kernelspec list

and then remove the kernel that is at C:\Users\sk_np\AppData\Roaming\Python\Python38 with

jupyter kernelspec remove <kernelName>


问:
Pie Chart Center Text gets overlap with tooltip
I am using a Pie chart of HighChart lib. On hover over of pie, the center text is getting overlapped with the tooltip. Is there any solution to fix this?

link to stackblitz
https://stackblitz.com/edit/pie-chart-using-highcharts-er7kym?file=app%2Fhighcharts.service.ts

答:
Something in the settings was wrong, I created a similar chart from the demo and here the text no longer overlaps the tooltip.

```<code>Highcharts.chart('container', {
  chart: {
    plotBackgroundColor: null,
    plotBorderWidth: 0,
    plotShadow: false
  },
  title: {
    text: 'Browser<br>shares<br>2017',
    align: 'center',
    verticalAlign: 'middle',
    y: 60
  },
  tooltip: {
    pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
  },
  plotOptions: {
    pie: {
      allowPointSelect: true,
      showInLegend: true,
      cursor: 'pointer',
      innerSize: '50%',
      dataLabels: {
        enabled: false,
        format: '<b><a (click)="helloFunc(point.name)">{point.name}</a></b>: {point.percentage:.1f} %bbb',
        style: {
          color: (Highcharts.theme && Highcharts.theme.contrastTextColor) ||
            'black',
        },
      },
      states: {
        hover: {
          brightness: 0,
          halo: {
            opacity: 1,
          },
        },
        select: {
          brightness: 0,
          halo: {
            opacity: 1,
          },
        },
      },
      point: {
        events: {
          mouseOver: function() {
            let chart = this.series.chart;
            chart.title.attr({
              text: `<span style="color:#e43761;" class="dealer-title" data-oa-qa="donut-total-count-text">Total<br/><b>${this.y}</b></span>`,
            });
          },
          click: function() {
            let chart = this.series.chart;
            chart.title.attr({
              text: `<span style="color:#e43761;" class="dealer-title" data-oa-qa="donut-total-count-text">Total<br/><b>${this.y}</b></span>`,
            });
          },
          legendItemClick: function() {
            let chart = this.series.chart;
            chart.title.attr({
              text: `<span style="color:#e43761;" class="dealer-title" data-oa-qa="donut-total-count-text">Total<br/><b>${this.y}</b></span>`,
            });
            return false;
          },
        },
      },
    },
  },
  series: [{
    type: 'pie',
    name: 'Browser share',
    innerSize: '50%',
    data: [
      ['Chrome', 58.9],
      ['Firefox', 13.29],
      ['Internet Explorer', 13],
      ['Edge', 3.78],
      ['Safari', 3.42],
      {
        name: 'Other',
        y: 7.61,
        dataLabels: {
          enabled: false
        }
      }
    ]
  }]
});
</code>```

Example recreated in Angular: Demo

Body:
Something in the settings was wrong, I created a similar chart from the demo and here the text no longer overlaps the tooltip.

Highcharts.chart('container', {
  chart: {
    plotBackgroundColor: null,
    plotBorderWidth: 0,
    plotShadow: false
  },
  title: {
    text: 'Browser<br>shares<br>2017',
    align: 'center',
    verticalAlign: 'middle',
    y: 60
  },
  tooltip: {
    pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
  },
  plotOptions: {
    pie: {
      allowPointSelect: true,
      showInLegend: true,
      cursor: 'pointer',
      innerSize: '50%',
      dataLabels: {
        enabled: false,
        format: '<b><a (click)="helloFunc(point.name)">{point.name}</a></b>: {point.percentage:.1f} %bbb',
        style: {
          color: (Highcharts.theme && Highcharts.theme.contrastTextColor) ||
            'black',
        },
      },
      states: {
        hover: {
          brightness: 0,
          halo: {
            opacity: 1,
          },
        },
        select: {
          brightness: 0,
          halo: {
            opacity: 1,
          },
        },
      },
      point: {
        events: {
          mouseOver: function() {
            let chart = this.series.chart;
            chart.title.attr({
              text: `<span style="color:#e43761;" class="dealer-title" data-oa-qa="donut-total-count-text">Total<br/><b>${this.y}</b></span>`,
            });
          },
          click: function() {
            let chart = this.series.chart;
            chart.title.attr({
              text: `<span style="color:#e43761;" class="dealer-title" data-oa-qa="donut-total-count-text">Total<br/><b>${this.y}</b></span>`,
            });
          },
          legendItemClick: function() {
            let chart = this.series.chart;
            chart.title.attr({
              text: `<span style="color:#e43761;" class="dealer-title" data-oa-qa="donut-total-count-text">Total<br/><b>${this.y}</b></span>`,
            });
            return false;
          },
        },
      },
    },
  },
  series: [{
    type: 'pie',
    name: 'Browser share',
    innerSize: '50%',
    data: [
      ['Chrome', 58.9],
      ['Firefox', 13.29],
      ['Internet Explorer', 13],
      ['Edge', 3.78],
      ['Safari', 3.42],
      {
        name: 'Other',
        y: 7.61,
        dataLabels: {
          enabled: false
        }
      }
    ]
  }]
});

Example recreated in Angular: Demo


问:
Serialized Arrray in TCPDF not showing properly
Good Day

I have a serialized array having records in MYSQL
When I display them browser, results are fine (by unserializing and displaying)
When I show in TCPDF, it returns only one record (total are 2 3 records)

I am putting them in loop and using same logic as using in browser too

Below is the code I am trying in TCPDF

Thanks

```<code>$query1 = "SELECT * from fine_controls WHERE formid='$emp_id'";
        $resulty = mysqli_query($link, $query1);

        while($row22 = mysqli_fetch_assoc($resulty)){
            $fine_typesR = unserialize($row22['fine_type']);
        }
    foreach ($fine_typesR as $fine_typet) { $f= $fine_typet;    }
  $pdf->writeHTML($f, true, false, false, false, '');
</code>```

Above code shows only one value suppose values are 3 and 7 I get only one record 3. I don't know why is this happening

Thanks

答:
As KenLee said, Put  $pdf->writeHTML in loop too so it worked

Thanks

```<code>$query1 = "SELECT * from fine_controls WHERE formid='$emp_id'";
        $resulty = mysqli_query($link, $query1);

        while($row22 = mysqli_fetch_assoc($resulty)){
            $fine_typesR = unserialize($row22['fine_type']);
        }
    foreach ($fine_typesR as $fine_typet) { $f= $fine_typet;
  $pdf->writeHTML($f, true, false, false, false, '');

}
</code>```

Body:
Good Day

I have a serialized array having records in MYSQL
When I display them browser, results are fine (by unserializing and displaying)
When I show in TCPDF, it returns only one record (total are 2 3 records)

I am putting them in loop and using same logic as using in browser too

Below is the code I am trying in TCPDF

Thanks

$query1 = "SELECT * from fine_controls WHERE formid='$emp_id'";
        $resulty = mysqli_query($link, $query1);

        while($row22 = mysqli_fetch_assoc($resulty)){
            $fine_typesR = unserialize($row22['fine_type']);
        }
    foreach ($fine_typesR as $fine_typet) { $f= $fine_typet;    }
  $pdf->writeHTML($f, true, false, false, false, '');

Above code shows only one value suppose values are 3 and 7 I get only one record 3. I don't know why is this happening

Thanks

Body:
As KenLee said, Put  $pdf->writeHTML in loop too so it worked

Thanks

$query1 = "SELECT * from fine_controls WHERE formid='$emp_id'";
        $resulty = mysqli_query($link, $query1);

        while($row22 = mysqli_fetch_assoc($resulty)){
            $fine_typesR = unserialize($row22['fine_type']);
        }
    foreach ($fine_typesR as $fine_typet) { $f= $fine_typet;
  $pdf->writeHTML($f, true, false, false, false, '');

}


问:
Firebase Crashlytics | Swift Package Manager (SPM) Run Script?
I want to add Crashlytics to my app using the Swift package manager.

Now, since the usual way to install Firebase is through CocoaPods, the  tutorial on how to set up Crashlytics properly is also adjusted for CocoaPods.

In other words - the run script we should copy from the tutorial is not compatible with SPM, as you can see here:

```<code>${PODS_ROOT}/FirebaseCrashlytics/run
</code>```

So how can I find the file location of Crashlytics using SPM to get the correct run script?

Thanks!

答:
Add a package by selecting File → Add Packages… in Xcode’s menu bar.

Search for the Firebase Apple SDK using the repo's URL:

```<code>https://github.com/firebase/firebase-ios-sdk.git
</code>```

Next, set the Dependency Rule to be Up to Next Major Version and specify 8.10.0 as the lower bound.

Then, select Add Package.

Choose the Firebase products that you want installed in your app.

If you've installed FirebaseAnalytics, add the -ObjC option to Other Linker Flags in the Build Settings tab.

Body:
I want to add Crashlytics to my app using the Swift package manager.

Now, since the usual way to install Firebase is through CocoaPods, the  tutorial on how to set up Crashlytics properly is also adjusted for CocoaPods.

In other words - the run script we should copy from the tutorial is not compatible with SPM, as you can see here:

${PODS_ROOT}/FirebaseCrashlytics/run

So how can I find the file location of Crashlytics using SPM to get the correct run script?

Thanks!

Body:
Add a package by selecting File → Add Packages… in Xcode’s menu bar.

Search for the Firebase Apple SDK using the repo's URL:

https://github.com/firebase/firebase-ios-sdk.git

Next, set the Dependency Rule to be Up to Next Major Version and specify 8.10.0 as the lower bound.

Then, select Add Package.

Choose the Firebase products that you want installed in your app.

If you've installed FirebaseAnalytics, add the -ObjC option to Other Linker Flags in the Build Settings tab.


问:
Why can't I use <Class>.this in anonymous class?
I recently use this code, and realize that in anonymous class, I can't access the instance by .this, like this:

```<code>Sprite sprFace = new Sprite() {

    @Override
    protected void onManagedUpdate(float pSecondElapsed) {
        runOnUpdateThread(new Runnable() {

        @Override
        protected void run() {
            Sprite.this.getParent().detach(Sprite.this); // Here
        }});
    }

};
</code>```

I know how to solve it (just declare a "me" variable), but I need to know why I can't use <Class>.this?

答:
The <Class>.this syntax gives a special way of referring to the object of type <Class>, as opposed to the shadowing type.

In addition, <Class> must be the name of the type you're trying to access. In your case, Sprite is not the actual type of sprFace. Rather, sprFace is an instance of an anonymous subclass of Sprite, thus the syntax is not applicable.

Body:
I recently use this code, and realize that in anonymous class, I can't access the instance by .this, like this:

Sprite sprFace = new Sprite() {

    @Override
    protected void onManagedUpdate(float pSecondElapsed) {
        runOnUpdateThread(new Runnable() {

        @Override
        protected void run() {
            Sprite.this.getParent().detach(Sprite.this); // Here
        }});
    }

};

I know how to solve it (just declare a "me" variable), but I need to know why I can't use <Class>.this?


问:
Google sheets fill in the gaps using array formula

I have this table and the date column has some blanks if the dates are the same.
i.e. B3:B6 are all 31/01/2022
I want to use column F to fill in the gaps.

I would like to use an arrayformula in cell F2 and it stops when the relative A is empty
i.e. if A279 is empty, F279 is empty too.

I tried to do it using a non-array solution
=IF(B2="",F1,B2)

and I cannot change it to array one
=ArrayFormula(IF(B2:B="",F1,B2:B))

I don't know how to make F1 dynamic and the row number is always one less then B, like showing F2 if B3, F3 if B4

This is the Sheet

答:
Try in F2

```<code>=ArrayFormula(lookup(row(A2:A),row(A2:A)/--(B2:B<>""),B2:B))
</code>```

or (better) in F1

```<code>={"Date";ArrayFormula(if(A2:A="",,lookup(row(A2:A),row(A2:A)/--(B2:B<>""),B2:B)))}
</code>```

to understand how it works, pls fill for instance in I2 =arrayformula(if(A2:A="",,row(A2:A)/--(B2:B<>""))) ... if Bx is blank, we get an error, in that case lookup will take the previous value without error.

Body:
Try in F2

=ArrayFormula(lookup(row(A2:A),row(A2:A)/--(B2:B<>""),B2:B))

or (better) in F1

={"Date";ArrayFormula(if(A2:A="",,lookup(row(A2:A),row(A2:A)/--(B2:B<>""),B2:B)))}

to understand how it works, pls fill for instance in I2 =arrayformula(if(A2:A="",,row(A2:A)/--(B2:B<>""))) ... if Bx is blank, we get an error, in that case lookup will take the previous value without error.