问:
Not able to login with mesibo chat SDK
I'm trying to implement chat using Xcode Framework i have download sample app for iOS. I'm not able to login the username and password which i have created in server. I'm using Swift for mesibo chat their i have created user's but I'm not able login.</p>

答:
Mesibo says :"Demo app uses AccountKit which is deprecated, how to replace it?
Mesibo has no dependencies on AccountKit. The AccountKit is only used as a method in the demo apps. You can use whatever authentication method as you prefer, for example, sending OTP using SMS providers. Since the complete demo app source code is available on GitHub, you can remove AccountKit and replace it with your own screens."</p>

Title: Not able to login with mesibo chat SDK


来源: stackexchange

问:
Is there how to get rows as it is being displayed on AG-GRID?
I'm having a really hard time to implement a MOVE-TO feature on ag-grid.

The objective is to jump to a visible cell after pressing enter on an external input text.

Currently I'm calling forEachNodeAfterFilterAndSort for retrieve rows that are being displayed. But is not that simple when you start to deal with groups, orgHierachy, hidden columns, etc.

So, is there a way to get something like that on ag-grid api?

e.g.

```<code>  _________________
  |  A    |  B    |
  -----------------
0)| Loris | Ipsum |
1)|       | foo   |
2)|       | bar   |
  -----------------
</code>```

GetRowsAsTheyREALLYAre:

```<code>[
   {index:0, A='Loris', B="Ipsum"},
   {index:1, B="foo"},
   {index:2, B="bar"}
]
</code>```

答:
As per the Ag-Gird documentation use getDisplayedRowCount(); for getting visiable rows.

ex

```<code> getAllDisplayedRows() {
    var count = this.gridApi.getDisplayedRowCount();
       for (var i = 0; i < count; i++) {
      var rowNode = this.gridApi.getDisplayedRowAtIndex(i);
      console.log("row " + i + " is " + rowNode.data);
    }
  }
</code>```

Read this

ContentLicense: CC BY-SA 4.0

Body:
I'm having a really hard time to implement a MOVE-TO feature on ag-grid.

The objective is to jump to a visible cell after pressing enter on an external input text.

Currently I'm calling forEachNodeAfterFilterAndSort for retrieve rows that are being displayed. But is not that simple when you start to deal with groups, orgHierachy, hidden columns, etc.

So, is there a way to get something like that on ag-grid api?

e.g.

  _________________
  |  A    |  B    |
  -----------------
0)| Loris | Ipsum |
1)|       | foo   |
2)|       | bar   |
  -----------------

GetRowsAsTheyREALLYAre:

[
   {index:0, A='Loris', B="Ipsum"},
   {index:1, B="foo"},
   {index:2, B="bar"}
]

Body:
As per the Ag-Gird documentation use getDisplayedRowCount(); for getting visiable rows.

ex

 getAllDisplayedRows() {
    var count = this.gridApi.getDisplayedRowCount();
       for (var i = 0; i < count; i++) {
      var rowNode = this.gridApi.getDisplayedRowAtIndex(i);
      console.log("row " + i + " is " + rowNode.data);
    }
  }

Read this


问:
SQL proc to calculate check digit for 7 and 12 digit upc
I just had to scour the internet for this code yet again so I figured I would put it here so I can find it a little faster the next time and hopefully you found it a little faster too :)</p>

答:
Here's my implementation of a function in Oracle. </p>

```<code>CREATE OR REPLACE FUNCTION GenerateCheckDigit(pUPC IN VARCHAR2) RETURN INT
  IS
  vCheckDigit INT;
  BEGIN

    WITH barcodeData AS
    (
      SELECT pUPC barcode FROM dual
    )
    SELECT
      10-REPLACE(MOD(SUM(SUBSTR(barcode, -LEVEL, 1) * DECODE(MOD(LEVEL-1, 2), 1, 1, 3)),10),0,10) INTO vCheckDigit
      FROM barcodeData
    CONNECT BY LEVEL <= LENGTH(barcode);

    RETURN vCheckDigit;

  END;
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Here's my implementation of a function in Oracle.

CREATE OR REPLACE FUNCTION GenerateCheckDigit(pUPC IN VARCHAR2) RETURN INT
  IS
  vCheckDigit INT;
  BEGIN

    WITH barcodeData AS
    (
      SELECT pUPC barcode FROM dual
    )
    SELECT
      10-REPLACE(MOD(SUM(SUBSTR(barcode, -LEVEL, 1) * DECODE(MOD(LEVEL-1, 2), 1, 1, 3)),10),0,10) INTO vCheckDigit
      FROM barcodeData
    CONNECT BY LEVEL <= LENGTH(barcode);

    RETURN vCheckDigit;

  END;


问:
How to reset CheckBox buttonDrawable to default
When I add a CheckBox to a layout it has some button drawable assigned by default, particularly Android Studio shows it in the attributes pannel as

```<code>button: @android:drawable/btn_check_material_anim
</code>```

If I change it to some other drawable, how can I reset it back to the default one programmically?

答:
Edit 1: to support lower api level ( < 23) use this:

```<code>val compatBak = CompoundButtonCompat.getButtonDrawable(cb)
// cb is your CheckBox
</code>```

Edit: Backing up the ButtonDrawable:

To set the default attribute, we'll store default attribute somewhere, before changing it (avoid changing it in xml, as you can change it dynamically & it'll allow you to make a backup), (annotate onCreate() with @RequiresApi(Build.VERSION_CODES.M) and save it before changing, later on you can use it.

```<code>val bak = cb.buttonDrawable
// re setting..
cb.buttonDrawable = bak;
</code>```

or in Java:

```<code>CheckBox cb = findViewById(R.id.cb);
Drawable buttonDrawable = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
    buttonDrawable = cb.getButtonDrawable();
}

// later on..
cb.setButtonDrawable(buttonDrawable);
</code>```

End of edit

I assume you're asking to change/set the android:button attribute of your CheckBox.
Here's how you can do it programmatically:

View:

```<code> <CheckBox
        android:id="@+id/checkBox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:button="@drawable/cb_drawable" />
</code>```

Activity:

If you're using java:

```<code>CheckBox cb = findViewById(R.id.checkBox);
cb.setButtonDrawable(R.drawable.cb_drawable);
</code>```

Or in kotlin:

```<code>val cBox = findViewById<CheckBox>(R.id.checkBox)
cBox.buttonDrawable = ContextCompat.getDrawable(this, R.drawable.cb_drawable)

// or just use synthetic
checkBox.buttonDrawable = ContextCompat.getDrawable(this, R.drawable.cb_drawable)
</code>```

ContextCompat or you can use getDrawable(). Here  R.drawable.cb_drawable is the desired drawable we want to set. Make cb_drawable.xml under the drawable folder.

Body:
When I add a CheckBox to a layout it has some button drawable assigned by default, particularly Android Studio shows it in the attributes pannel as

button: @android:drawable/btn_check_material_anim

If I change it to some other drawable, how can I reset it back to the default one programmically?

Body:
Edit 1: to support lower api level ( < 23) use this:

val compatBak = CompoundButtonCompat.getButtonDrawable(cb)
// cb is your CheckBox

Edit: Backing up the ButtonDrawable:

To set the default attribute, we'll store default attribute somewhere, before changing it (avoid changing it in xml, as you can change it dynamically & it'll allow you to make a backup), (annotate onCreate() with @RequiresApi(Build.VERSION_CODES.M) and save it before changing, later on you can use it.

val bak = cb.buttonDrawable
// re setting..
cb.buttonDrawable = bak;

or in Java:

CheckBox cb = findViewById(R.id.cb);
Drawable buttonDrawable = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
    buttonDrawable = cb.getButtonDrawable();
}

// later on..
cb.setButtonDrawable(buttonDrawable);

End of edit

I assume you're asking to change/set the android:button attribute of your CheckBox.
Here's how you can do it programmatically:

View:

 <CheckBox
        android:id="@+id/checkBox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:button="@drawable/cb_drawable" />

Activity:

If you're using java:

CheckBox cb = findViewById(R.id.checkBox);
cb.setButtonDrawable(R.drawable.cb_drawable);

Or in kotlin:

val cBox = findViewById<CheckBox>(R.id.checkBox)
cBox.buttonDrawable = ContextCompat.getDrawable(this, R.drawable.cb_drawable)

// or just use synthetic
checkBox.buttonDrawable = ContextCompat.getDrawable(this, R.drawable.cb_drawable)

ContextCompat or you can use getDrawable(). Here  R.drawable.cb_drawable is the desired drawable we want to set. Make cb_drawable.xml under the drawable folder.


问:
ef core navigation property fails to load
My application is Ef core 2.2 , Lazy loading not enabled.

At MapAddress method address object's Country object is null, although i have

Include(a => a.Address).ThenInclude(a => a.Country)

to load country eagerly.

```<code>   var agentWalletResponse = (from wd in dbContext.WalletDetail.Where(w => w.WalletDetailId == agentWalletDetailId)
                                    join c in dbContext.CorporateInfo.Include(a => a.Address).ThenInclude(a => a.Country).Where(d => !d.IsDeleted) on wd.WalletSubscriptionId equals c.OwnerUserId
                                    select new AgentWalletResponse()
                                    {

                                        Address = MapAddress(c.Address),
                                        Balance = wd.AvailableBalance,
                                        CreatedOn = wd.CreatedOn
                                    }).FirstOrDefault();
</code>```

Map address

```<code> protected AddressModel MapAddress(Address address)
    {
        if (address == null)
            return null;

        return new AddressModel
        {
            AddressId = address.AddressId,
            AddressLine = address.AddressLine1,
            City = address.City,
            Country = address.Country?.Name,
            Province = address.Province,
            Division = address.Division,
            PhoneNumber = address.PhoneNumber,
            PostalCode = address.PostalCode
        };
    }
</code>```

答:
change the then include expression.

join c in dbContext.CorporateInfo.Include(a => a.Address).ThenInclude(a => a.Address.Country)...

Body:
My application is Ef core 2.2 , Lazy loading not enabled.

At MapAddress method address object's Country object is null, although i have

Include(a => a.Address).ThenInclude(a => a.Country)

to load country eagerly.

   var agentWalletResponse = (from wd in dbContext.WalletDetail.Where(w => w.WalletDetailId == agentWalletDetailId)
                                    join c in dbContext.CorporateInfo.Include(a => a.Address).ThenInclude(a => a.Country).Where(d => !d.IsDeleted) on wd.WalletSubscriptionId equals c.OwnerUserId
                                    select new AgentWalletResponse()
                                    {

                                        Address = MapAddress(c.Address),
                                        Balance = wd.AvailableBalance,
                                        CreatedOn = wd.CreatedOn
                                    }).FirstOrDefault();

Map address

 protected AddressModel MapAddress(Address address)
    {
        if (address == null)
            return null;

        return new AddressModel
        {
            AddressId = address.AddressId,
            AddressLine = address.AddressLine1,
            City = address.City,
            Country = address.Country?.Name,
            Province = address.Province,
            Division = address.Division,
            PhoneNumber = address.PhoneNumber,
            PostalCode = address.PostalCode
        };
    }


问:
Can't find variable: counter, in expo
Been using React for a bit and wanted to try out native using expo, when I click on a button to increment a counter, I get a ReferenceError on my phone saying "Can't find variable: counter", I don't get any error on the expo gui or in VSCode, very confused.</p>

```<code>import React from "react";
import { StyleSheet, Text, View } from "react-native";
import { Button } from "react-native-elements";

export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      counter: 0
    };
  }

  increment() {
    this.setState({ counter: (counter += 1) });
  }

  render() {
    return (
      <View style={styles.container}>
        <Text>Open up App.js to start working on your app!</Text>
        <Text>{this.state.counter}</Text>
        <Button title="Press Me" onPress={this.increment}></Button>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center"
  }
});

</code>```

答:
So there are 2 ways of doing it, either you change your increment function to a fat arrow function or bind the this scope of function in constructor, Its basically how this scope gets binded:

```<code>increment = () => {
    this.setState({ counter: (counter += 1) });
  }
</code>```

another way is :

```<code>export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      counter: 0
    };
this.increment = this.increment.bind(this); // new addition
  }

  increment() {
    this.setState({ counter: (counter += 1) });
  }

  render() {
    return (
      <View style={styles.container}>
        <Text>Open up App.js to start working on your app!</Text>
        <Text>{this.state.counter}</Text>
        <Button title="Press Me" onPress={this.increment}></Button>
      </View>
    );
  }
}
</code>```

Hope it gets clear, these are the 2 ways. Feel free for doubts

Title: Can't find variable: counter, in expo

Body:
Been using React for a bit and wanted to try out native using expo, when I click on a button to increment a counter, I get a ReferenceError on my phone saying "Can't find variable: counter", I don't get any error on the expo gui or in VSCode, very confused.

import React from "react";
import { StyleSheet, Text, View } from "react-native";
import { Button } from "react-native-elements";

export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      counter: 0
    };
  }

  increment() {
    this.setState({ counter: (counter += 1) });
  }

  render() {
    return (
      <View style={styles.container}>
        <Text>Open up App.js to start working on your app!</Text>
        <Text>{this.state.counter}</Text>
        <Button title="Press Me" onPress={this.increment}></Button>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center"
  }
});

Body:
So there are 2 ways of doing it, either you change your increment function to a fat arrow function or bind the this scope of function in constructor, Its basically how this scope gets binded:

increment = () => {
    this.setState({ counter: (counter += 1) });
  }

another way is :

export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      counter: 0
    };
this.increment = this.increment.bind(this); // new addition
  }

  increment() {
    this.setState({ counter: (counter += 1) });
  }

  render() {
    return (
      <View style={styles.container}>
        <Text>Open up App.js to start working on your app!</Text>
        <Text>{this.state.counter}</Text>
        <Button title="Press Me" onPress={this.increment}></Button>
      </View>
    );
  }
}

Hope it gets clear, these are the 2 ways. Feel free for doubts


问:
Is it better to create persistent stores, or use fixed files for data?
I'm prototyping a simple sports sim game for iPhone which will use Core data.

One the biggest challenges I'm facing is how to get the data into Core data in the first place.

The second biggest challenge is whether I should use core data's persistent stores or use fixed files (JSON) for pre-fixed game data.

--

Concept

The general concept is that a player can start a new game or continue an existing one.

When they start new game they would use pre-fixed data. (IE. A database which is read-only.)

When they continue game they would use a different database (the game database).

I am not sure how to deliver such a feature.

--

Prototype

Currently, I am experimenting with this prototype:

PHP Web App -> 2. API -> 3. iPhone

A local PHP web app which acts as a CMS.

A basic API which lets me expose specific data in a JSON format.

Read the JSON into Core Data using TouchJSON/other tools.

I have no intention of making the API public/online (for various reasons), so the method I have described is a only meant to ever be a one-way process.

This will of course cause a problem because I need to make the data read-only.

--

In sports sim games you will often find them using fixed files (.txt, .csv, .dat, etc) and then they read this data into memory or a database.

Therefore, using this concept I could:

Save the JSON as fixed files and read them at run-time into memory/core data.

And then whenever the player starts a new game, the existing core data store will simply be wiped.

However, having said that I've heard that you can use persistent stores as a method to overcome this problem.

Therefore I was thinking of setting up 2 persistent stores;

1) A pre-fixed read-only persistent store

2) The actual game store (which gets overwritten if you start a new game).

But which is better?

Creating JSON fixed files for consumption, or using 2 persistent stores?

I apologize if my question/concept is overly complex; but would welcome better/simpler solutions where possible.

答: I think you can use Core Data for applications that is going to store data on it and the database is empty when it starts but if you needed you data store to be pre-populated with data it is better to load it from fixed data like sqlite or xml files.</p>


问:
Select same column name in microsoft sql server from multiple tables
Is it possible to write a query:

```<code>SELECT * from table1, table 2, table 3 ...
</code>```

where table1.column name like table2.column name like table3.column name

We don't know the name of our column, we say any of our columns which are in table1.column name like table2.column name  in like  table3.column name

For example: employee id maybe is a column that is common to 3 tables, or publisher id is a column that is common to 3 tables.

I can find the foreign key or primary key with a diagram in my database, but I want to write a query that shows just columns which have a same title as column name.

答:
If you know the column name and want to know in which different table same column name is used then write SQL query as

SELECT schema_name(t.[schema_id]) + '.' + t.[name] AS Tables FROM sys.tables t INNER JOIN sys.columns c on t.[object_id] = c.[object_id] WHERE c.[name] = 'Your_Common_Column_Name'

You will get all the table list with their respective schema

Body:
Is it possible to write a query:

SELECT * from table1, table 2, table 3 ...

where table1.column name like table2.column name like table3.column name

We don't know the name of our column, we say any of our columns which are in table1.column name like table2.column name  in like  table3.column name

For example: employee id maybe is a column that is common to 3 tables, or publisher id is a column that is common to 3 tables.

I can find the foreign key or primary key with a diagram in my database, but I want to write a query that shows just columns which have a same title as column name.


问:
How to compare XLS file to json file?
Hi I have a task to compare some XLS files to json files I have working code but the loop is comparing only first row from xls, does not go to the next one.

```<code>def verify_xlsx_file_content_against_json(json, xlsx_path):

    found_configs_ct = 0
    xlsx_reader = XLSXReader()
    data_frame = xlsx_reader.read_xlsx(xlsx_path, "Configuration Set")
    for config in json_definition:
        items_compared = 0
        for item in config["content"]["items"]:
            for index, row in data_frame.iterrows():
                if config["segAlias"] == row["Seg Alias"] and item["itemsOrder"] == row["Items Order"]:
                    found_configs_ct += 1
                    if index == 0:
                        def_platforms = config["platforms"]
                        platforms = ["gp", "ios", "win32", "fb", "amazon"]
                        for platform in platforms:
                            if platform in def_platforms:
                                assert_equal_values(row[convert_def_platform_to_excel_platform_name(platform)], "Y","{" + platform + "} should be True! and is not.")
                            else:
                                assert_equal_values(row[convert_def_platform_to_excel_platform_name(platform)], "N","{" + platform + "} should be False! and is not.")
                        name_from_definition = config["content"]["items"][0]["name"]  # all items have the same name thus index 0 is sufficient
                        assert_equal_values(row["Name"], name_from_definition, "Content name is invalid")
                    Logger.LogInfo(str(item["identifier"]) + ' identifier')
                    Logger.LogInfo(str(row["Identifier"]) + ' Identifier')
                    Logger.LogInfo(str(item["itemsOrder"]) + ' itemsOrder')
                    Logger.LogInfo(str(row["Items Order"]) + ' Items Order')
                    Logger.LogInfo(str(item["dValue"]) + ' dValue')
                    Logger.LogInfo(str(row["D Value, $"]) + ' D Value, $')
                    Logger.LogInfo(str(row["Pack Image"]) + ' PackImage from row  <<<<<<<<<<<<<<<')
                    Logger.LogInfo(str(item["packImage"]) + ' packImage second from item-<<<<<<<<')
                    assert_equal_values(str(item["identifier"]), str(row["Identifier"]), "Identifier is not match!")
                    assert_equal_values(str(item["itemsOrder"]), str(row["Items Order"]), "Items Order is not match!")
                    assert_equal_values(str(item["packImage"]), str(row["Pack Image"]), "packImage is not match!")
                    assert_equal_values(str(item["dValue"]), str(row["D Value, $"]),"dValue  not match!")
                    # assert_equal_values(str(item["remarks"]), str(row["Remarks"]), "Remarks is not match!")
                    items_compared += 1
                    break
        assert_equal_values(items_compared, len(
            config["content"]["items"]), "number of items compared is less than actual items")
    return False
    logging.info("verification done. ---no problems detected--")
    return True  # if code got here, no errors on the way, return True
</code>```

what I get here is

```<code>NFO:root:[2020-02-14 09:33:24.543957] 0 identifier
      INFO:root:[2020-02-14 09:33:24.543957] -1 Identifier
      INFO:root:[2020-02-14 09:33:24.543957] 1 itemsOrder
      INFO:root:[2020-02-14 09:33:24.543957] 1 Items Order
      INFO:root:[2020-02-14 09:33:24.543957] 1.99 dValue
      INFO:root:[2020-02-14 09:33:24.543957] 1.99 D Value, $
      INFO:root:[2020-02-14 09:33:24.544953] 1 identifier
      INFO:root:[2020-02-14 09:33:24.544953] -1 Identifier
      INFO:root:[2020-02-14 09:33:24.544953] 2 itemsOrder
      INFO:root:[2020-02-14 09:33:24.544953] 1 Items Order
      INFO:root:[2020-02-14 09:33:24.544953] 2.99 dValue
      INFO:root:[2020-02-14 09:33:24.544953] 1.99 D Value,
      INFO:root:[2020-02-14 09:33:24.544953] 2 identifier
      INFO:root:[2020-02-14 09:33:24.545949] -1 Identifier
</code>```

So -1 Identifier is always -1 and should change incrementally (0,1,2... ) like in json file.
How to change this loop to make this code work? and later to assert those files json vs xls

What I did

```<code>df = pd.read_excel("download1.xlsx") #xlsx to json
json_from_excel = df.to_json() #json string
print(type(json_from_excel))
print(json_from_excel)
final_dictionary = json.loads(json_from_excel) #dict
print(type(final_dictionary))
print(final_dictionary)

with open('basic.json', 'r') as jason_file:
    data = json.loads(jason_file.read())
    for item in data:
        print(type(item))
</code>```

and the result is

```<code><class 'str'>
{"Name":{"0":"default_config","1":"default_config","2":"default_config","3":"default_config","4":"default_config","5":"gems1","6":"gems1","7":"gems1","8":"gems1","9":"gems1","10":"gems2","11":"gems2","12":"gems2","13":"gems2","14":"gems2","15":"gems3","16":"gems3","17":"gems3","18":"gems3","19":"gems3"},"Identifier":{"0":11294,"1":11294,"2":11294,"3":11294,"4":11294,"5":11295,"6":11295,"7":11295,"8":11295,"9":11295,"10":11296,"11":11296,"12":11296,"13":11296,"14":11296,"15":11297,"16":11297,"17":11297,"18":11297,"19":11297},"Segment Alias":{"0":"default","1":"default","2":"default","3":"default","4":"default","5":"rhinoQA_1","6":"rhinoQA_1","7":"rhinoQA_1","8":"rhinoQA_1","9":"rhinoQA_1","10":"rhinoQA_2","11":"rhinoQA_2","12":"rhinoQA_2","13":"rhinoQA_2","14":"rhinoQA_2","15":"rhinoQA_3","16":"rhinoQA_3","17":"rhinoQA_3","18":"rhinoQA_3","19":"rhinoQA_3"},"Segment ID":{"0":-1,"1":-1,"2":-1,"3":-1,"4":-1,"5":95365,"6":95365,"7":95365,"8":95365,"9":95365,"10":95366,"11":95366,"12":95366,"13":95366,"14":95366,"15":95367,"16":95367,"17":95367,"18":95367,"19":95367},"GP":{"0":"Y","1":"Y","2":"Y","3":"Y","4":"Y","5":"N","6":"N","7":"N","8":"N","9":"N","10":"N","11":"N","12":"N","13":"N","14":"N","15":"N","16":"N","17":"N","18":"N","19":"N"},"iOS":{"0":"Y","1":"Y","2":"Y","3":"Y","4":"Y","5":"Y","6":"Y","7":"Y","8":"Y","9":"Y","10":"N","11":"N","12":"N","13":"N","14":"N","15":"N","16":"N","17":"N","18":"N","19":"N"},"FB":{"0":"Y","1":"Y","2":"Y","3":"Y","4":"Y","5":"N","6":"N","7":"N","8":"N","9":"N","10":"Y","11":"Y","12":"Y","13":"Y","14":"Y","15":"N","16":"N","17":"N","18":"N","19":"N"},"Amazon":{"0":"Y","1":"Y","2":"Y","3":"Y","4":"Y","5":"N","6":"N","7":"N","8":"N","9":"N","10":"N","11":"N","12":"N","13":"N","14":"N","15":"Y","16":"Y","17":"Y","18":"Y","19":"Y"},"Win32":{"0":"Y","1":"Y","2":"Y","3":"Y","4":"Y","5":"N","6":"N","7":"N","8":"N","9":"N","10":"N","11":"N","12":"N","13":"N","14":"N","15":"N","16":"N","17":"N","18":"N","19":"N"},"Remarks":{"0":"default;A.request cfa for test user and any non existing platform to get default B. request user 520000000101987 (has segment in hbi redis,but not in config), any platform","1":"default;A.request cfa for test user and any non existing platform to get default B. request user 520000000101987 (has segment in hbi redis,but not in config), any platform","2":"default;A.request cfa for test user and any non existing platform to get default B. request user 520000000101987 (has segment in hbi redis,but not in config), any platform","3":"default;A.request cfa for test user and any non existing platform to get default B. request user 520000000101987 (has segment in hbi redis,but not in config), any platform","4":"default;A.request cfa for test user and any non existing platform to get default B. request user 520000000101987 (has segment in hbi redis,but not in config), any platform","5":"*inserted_by_automated_test*","6":"*inserted_by_automated_test*","7":"*inserted_by_automated_test*","8":"*inserted_by_automated_test*","9":"*inserted_by_automated_test*","10":"x1","11":"x1","12":"x1","13":"x1","14":"x1","15":"x3","16":"x3","17":"x3","18":"x3","19":"x3"},"Pack Name":{"0":"test_bingo","1":"test_bingo","2":"test_bingo","3":"test_bingo","4":"test_bingo","5":"test_bingo","6":"test_bingo","7":"test_bingo","8":"test_bingo","9":"test_bingo","10":"test_bingo","11":"test_bingo","12":"test_bingo","13":"test_bingo","14":"test_bingo","15":"test_bingo","16":"test_bingo","17":"test_bingo","18":"test_bingo","19":"test_bingo"},"SKU":{"0":"gems_99","1":"gems_99","2":"gems_99","3":"gems_99","4":"gems_99","5":"gems_99","6":"gems_99","7":"gems_99","8":"gems_99","9":"gems_99","10":"gems_99","11":"gems_99","12":"gems_99","13":"gems_99","14":"gems_99","15":"gems_99","16":"gems_99","17":"gems_99","18":"gems_99","19":"gems_99"},"Sold Item":{"0":"Gems","1":"Gems","2":"Gems","3":"Gems","4":"Gems","5":"Gems","6":"Gems","7":"Gems","8":"Gems","9":"Gems","10":"Gems","11":"Gems","12":"Gems","13":"Gems","14":"Gems","15":"Gems","16":"Gems","17":"Gems","18":"Gems","19":"Gems"},"Items Order":{"0":1,"1":2,"2":3,"3":4,"4":5,"5":1,"6":2,"7":3,"8":4,"9":5,"10":1,"11":2,"12":3,"13":4,"14":5,"15":1,"16":2,"17":3,"18":4,"19":5},"Dollar Value, $":{"0":1.99,"1":2.99,"2":3.99,"3":4.99,"4":5.99,"5":1.99,"6":2.99,"7":3.99,"8":4.99,"9":5.99,"10":1.99,"11":11.99,"12":13.99,"13":14.99,"14":15.99,"15":1.99,"16":2.99,"17":3.99,"18":4.99,"19":5.99},"Item Quantity":{"0":5,"1":15,"2":25,"3":35,"4":45,"5":5,"6":15,"7":25,"8":55,"9":65,"10":5,"11":15,"12":45,"13":55,"14":75,"15":5,"16":15,"17":55,"18":95,"19":85},"Is Best":{"0":"Y","1":"Y","2":"Y","3":"Y","4":"Y","5":"Y","6":"Y","7":"Y","8":"Y","9":"Y","10":"Y","11":"Y","12":"Y","13":"Y","14":"Y","15":"Y","16":"Y","17":"Y","18":"Y","19":"Y"},"Is Popular":{"0":"N","1":"N","2":"N","3":"N","4":"N","5":"N","6":"N","7":"N","8":"N","9":"N","10":"N","11":"N","12":"N","13":"N","14":"N","15":"N","16":"N","17":"N","18":"N","19":"N"},"Footer Type":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1},"Footer Text":{"0":"test_text","1":"test_text","2":"test_text","3":"test_text","4":"test_text","5":"test_text","6":"test_text","7":"test_text","8":"test_text","9":"test_text","10":"test_text","11":"test_text","12":"test_text","13":"test_text","14":"test_text","15":"test_text","16":"test_text","17":"test_text","18":"test_text","19":"test_text"},"Pack Image":{"0":"gems_1.png","1":"gems_2.png","2":"gems_3.png","3":"gems_4.png","4":"gems_5.png","5":"gems_1.png","6":"gems_2.png","7":"gems_3.png","8":"gems_4.png","9":"gems_5.png","10":"gems_1.png","11":"gems_2.png","12":"gems_3.png","13":"gems_4.png","14":"gems_5.png","15":"gems_1.png","16":"gems_2.png","17":"gems_3.png","18":"gems_4.png","19":"gems_5.png"}}
<class 'dict'>
{'Name': {'0': 'default_config', '1': 'default_config', '2': 'default_config', '3': 'default_config', '4': 'default_config', '5': 'gems1', '6': 'gems1', '7': 'gems1', '8': 'gems1', '9': 'gems1', '10': 'gems2', '11': 'gems2', '12': 'gems2', '13': 'gems2', '14': 'gems2', '15': 'gems3', '16': 'gems3', '17': 'gems3', '18': 'gems3', '19': 'gems3'}, 'Identifier': {'0': 11294, '1': 11294, '2': 11294, '3': 11294, '4': 11294, '5': 11295, '6': 11295, '7': 11295, '8': 11295, '9': 11295, '10': 11296, '11': 11296, '12': 11296, '13': 11296, '14': 11296, '15': 11297, '16': 11297, '17': 11297, '18': 11297, '19': 11297}, 'Segment Alias': {'0': 'default', '1': 'default', '2': 'default', '3': 'default', '4': 'default', '5': 'rhinoQA_1', '6': 'rhinoQA_1', '7': 'rhinoQA_1', '8': 'rhinoQA_1', '9': 'rhinoQA_1', '10': 'rhinoQA_2', '11': 'rhinoQA_2', '12': 'rhinoQA_2', '13': 'rhinoQA_2', '14': 'rhinoQA_2', '15': 'rhinoQA_3', '16': 'rhinoQA_3', '17': 'rhinoQA_3', '18': 'rhinoQA_3', '19': 'rhinoQA_3'}, 'Segment ID': {'0': -1, '1': -1, '2': -1, '3': -1, '4': -1, '5': 95365, '6': 95365, '7': 95365, '8': 95365, '9': 95365, '10': 95366, '11': 95366, '12': 95366, '13': 95366, '14': 95366, '15': 95367, '16': 95367, '17': 95367, '18': 95367, '19': 95367}, 'GP': {'0': 'Y', '1': 'Y', '2': 'Y', '3': 'Y', '4': 'Y', '5': 'N', '6': 'N', '7': 'N', '8': 'N', '9': 'N', '10': 'N', '11': 'N', '12': 'N', '13': 'N', '14': 'N', '15': 'N', '16': 'N', '17': 'N', '18': 'N', '19': 'N'}, 'iOS': {'0': 'Y', '1': 'Y', '2': 'Y', '3': 'Y', '4': 'Y', '5': 'Y', '6': 'Y', '7': 'Y', '8': 'Y', '9': 'Y', '10': 'N', '11': 'N', '12': 'N', '13': 'N', '14': 'N', '15': 'N', '16': 'N', '17': 'N', '18': 'N', '19': 'N'}, 'FB': {'0': 'Y', '1': 'Y', '2': 'Y', '3': 'Y', '4': 'Y', '5': 'N', '6': 'N', '7': 'N', '8': 'N', '9': 'N', '10': 'Y', '11': 'Y', '12': 'Y', '13': 'Y', '14': 'Y', '15': 'N', '16': 'N', '17': 'N', '18': 'N', '19': 'N'}, 'Amazon': {'0': 'Y', '1': 'Y', '2': 'Y', '3': 'Y', '4': 'Y', '5': 'N', '6': 'N', '7': 'N', '8': 'N', '9': 'N', '10': 'N', '11': 'N', '12': 'N', '13': 'N', '14': 'N', '15': 'Y', '16': 'Y', '17': 'Y', '18': 'Y', '19': 'Y'}, 'Win32': {'0': 'Y', '1': 'Y', '2': 'Y', '3': 'Y', '4': 'Y', '5': 'N', '6': 'N', '7': 'N', '8': 'N', '9': 'N', '10': 'N', '11': 'N', '12': 'N', '13': 'N', '14': 'N', '15': 'N', '16': 'N', '17': 'N', '18': 'N', '19': 'N'}, 'Remarks': {'0': 'default;A.request cfa for test user and any non existing platform to get default B. request user 520000000101987 (has segment in hbi redis,but not in config), any platform', '1': 'default;A.request cfa for test user and any non existing platform to get default B. request user 520000000101987 (has segment in hbi redis,but not in config), any platform', '2': 'default;A.request cfa for test user and any non existing platform to get default B. request user 520000000101987 (has segment in hbi redis,but not in config), any platform', '3': 'default;A.request cfa for test user and any non existing platform to get default B. request user 520000000101987 (has segment in hbi redis,but not in config), any platform', '4': 'default;A.request cfa for test user and any non existing platform to get default B. request user 520000000101987 (has segment in hbi redis,but not in config), any platform', '5': '*inserted_by_automated_test*', '6': '*inserted_by_automated_test*', '7': '*inserted_by_automated_test*', '8': '*inserted_by_automated_test*', '9': '*inserted_by_automated_test*', '10': 'x1', '11': 'x1', '12': 'x1', '13': 'x1', '14': 'x1', '15': 'x3', '16': 'x3', '17': 'x3', '18': 'x3', '19': 'x3'}, 'Pack Name': {'0': 'test_bingo', '1': 'test_bingo', '2': 'test_bingo', '3': 'test_bingo', '4': 'test_bingo', '5': 'test_bingo', '6': 'test_bingo', '7': 'test_bingo', '8': 'test_bingo', '9': 'test_bingo', '10': 'test_bingo', '11': 'test_bingo', '12': 'test_bingo', '13': 'test_bingo', '14': 'test_bingo', '15': 'test_bingo', '16': 'test_bingo', '17': 'test_bingo', '18': 'test_bingo', '19': 'test_bingo'}, 'SKU': {'0': 'gems_99', '1': 'gems_99', '2': 'gems_99', '3': 'gems_99', '4': 'gems_99', '5': 'gems_99', '6': 'gems_99', '7': 'gems_99', '8': 'gems_99', '9': 'gems_99', '10': 'gems_99', '11': 'gems_99', '12': 'gems_99', '13': 'gems_99', '14': 'gems_99', '15': 'gems_99', '16': 'gems_99', '17': 'gems_99', '18': 'gems_99', '19': 'gems_99'}, 'Sold Item': {'0': 'Gems', '1': 'Gems', '2': 'Gems', '3': 'Gems', '4': 'Gems', '5': 'Gems', '6': 'Gems', '7': 'Gems', '8': 'Gems', '9': 'Gems', '10': 'Gems', '11': 'Gems', '12': 'Gems', '13': 'Gems', '14': 'Gems', '15': 'Gems', '16': 'Gems', '17': 'Gems', '18': 'Gems', '19': 'Gems'}, 'Items Order': {'0': 1, '1': 2, '2': 3, '3': 4, '4': 5, '5': 1, '6': 2, '7': 3, '8': 4, '9': 5, '10': 1, '11': 2, '12': 3, '13': 4, '14': 5, '15': 1, '16': 2, '17': 3, '18': 4, '19': 5}, 'Dollar Value, $': {'0': 1.99, '1': 2.99, '2': 3.99, '3': 4.99, '4': 5.99, '5': 1.99, '6': 2.99, '7': 3.99, '8': 4.99, '9': 5.99, '10': 1.99, '11': 11.99, '12': 13.99, '13': 14.99, '14': 15.99, '15': 1.99, '16': 2.99, '17': 3.99, '18': 4.99, '19': 5.99}, 'Item Quantity': {'0': 5, '1': 15, '2': 25, '3': 35, '4': 45, '5': 5, '6': 15, '7': 25, '8': 55, '9': 65, '10': 5, '11': 15, '12': 45, '13': 55, '14': 75, '15': 5, '16': 15, '17': 55, '18': 95, '19': 85}, 'Is Best': {'0': 'Y', '1': 'Y', '2': 'Y', '3': 'Y', '4': 'Y', '5': 'Y', '6': 'Y', '7': 'Y', '8': 'Y', '9': 'Y', '10': 'Y', '11': 'Y', '12': 'Y', '13': 'Y', '14': 'Y', '15': 'Y', '16': 'Y', '17': 'Y', '18': 'Y', '19': 'Y'}, 'Is Popular': {'0': 'N', '1': 'N', '2': 'N', '3': 'N', '4': 'N', '5': 'N', '6': 'N', '7': 'N', '8': 'N', '9': 'N', '10': 'N', '11': 'N', '12': 'N', '13': 'N', '14': 'N', '15': 'N', '16': 'N', '17': 'N', '18': 'N', '19': 'N'}, 'Footer Type': {'0': 1, '1': 1, '2': 1, '3': 1, '4': 1, '5': 1, '6': 1, '7': 1, '8': 1, '9': 1, '10': 1, '11': 1, '12': 1, '13': 1, '14': 1, '15': 1, '16': 1, '17': 1, '18': 1, '19': 1}, 'Footer Text': {'0': 'test_text', '1': 'test_text', '2': 'test_text', '3': 'test_text', '4': 'test_text', '5': 'test_text', '6': 'test_text', '7': 'test_text', '8': 'test_text', '9': 'test_text', '10': 'test_text', '11': 'test_text', '12': 'test_text', '13': 'test_text', '14': 'test_text', '15': 'test_text', '16': 'test_text', '17': 'test_text', '18': 'test_text', '19': 'test_text'}, 'Pack Image': {'0': 'gems_1.png', '1': 'gems_2.png', '2': 'gems_3.png', '3': 'gems_4.png', '4': 'gems_5.png', '5': 'gems_1.png', '6': 'gems_2.png', '7': 'gems_3.png', '8': 'gems_4.png', '9': 'gems_5.png', '10': 'gems_1.png', '11': 'gems_2.png', '12': 'gems_3.png', '13': 'gems_4.png', '14': 'gems_5.png', '15': 'gems_1.png', '16': 'gems_2.png', '17': 'gems_3.png', '18': 'gems_4.png', '19': 'gems_5.png'}}
{'id': 0, 'segmentAlias': 'default', 'userIds': [-1], 'platforms': ['gp'], 'content': {'items': [{'name': 'default_config', 'identifier': 0, 'itemsOrder': 1, 'dollarValue': 1.99, 'remarks': 'default!', 'itemsQuantity': 5, 'is_best': 'Y', 'is_popular': 'N', 'packName': 'test_bingo', 'footerType': 1, 'footerText': 'test_text', 'soldItem': 'Gems', 'packImage': 'gems_1.png', 'SKU': 'gems_99'}, {'name': 'default_config', 'identifier': 1, 'itemsOrder': 2, 'dollarValue': 2.99, 'remarks': 'default!', 'itemsQuantity': 15, 'is_best': 'Y', 'is_popular': 'N', 'packName': 'test_bingo', 'footerType': 1, 'footerText': 'test_text', 'soldItem': 'Gems', 'packImage': 'gems_2.png', 'SKU': 'gems_99'}, {'name': 'default_config', 'identifier': 2, 'itemsOrder': 3, 'dollarValue': 3.99, 'remarks': 'default!', 'itemsQuantity': 25, 'is_best': 'Y', 'is_popular': 'N', 'packName': 'test_bingo', 'footerType': 1, 'footerText': 'test_text', 'soldItem': 'Gems', 'packImage': 'gems_3.png', 'SKU': 'gems_99'}, {'name': 'default_config', 'identifier': 3, 'itemsOrder': 4, 'dollarValue': 4.99, 'remarks': 'default!', 'itemsQuantity': 35, 'is_best': 'Y', 'is_popular': 'N', 'packName': 'test_bingo', 'footerType': 1, 'footerText': 'test_text', 'soldItem': 'Gems', 'packImage': 'gems_4.png', 'SKU': 'gems_99'}, {'name': 'default_config', 'identifier': 4, 'itemsOrder': 5, 'dollarValue': 5.99, 'remarks': 'default!', 'itemsQuantity': 45, 'is_best': 'Y', 'is_popular': 'N', 'packName': 'test_bingo', 'footerType': 1, 'footerText': 'test_text', 'soldItem': 'Gems', 'packImage': 'gems_5.png', 'SKU': 'gems_99'}]}}
<class 'dict'>
{'id': 1, 'segmentAlias': 's1', 'userIds': [-1], 'platforms': ['ios'], 'content': {'items': [{'name': 'gems1', 'identifier': 0, 'itemsOrder': 1, 'dollarValue': 1.99, 'remarks': 'x', 'itemsQuantity': 5,
</code>```

I cannot compare those dicts

答:
You will need to read the excel file and convert it to json with pandas. Also check in which format is your json file when converting from pandas. Maybe you need to change the orientation.

```<code>df = pd.read_excel(xlsx, sheet_name=sheet)

json_from_excel = df.to_json(orient='records')
</code>```

Next you will need to order your json data here is an example function.

```<code>def ordered(obj):
    if isinstance(obj, dict):
        return sorted((k, ordered(v)) for k, v in obj.items())
    if isinstance(obj, list):
        return sorted(ordered(x) for x in obj)
    else:
        return obj
</code>```

And finally you can make the compare.

```<code>if ordered(json_from_excel) == ordered(json_data):
   #do something
</code>```

Title: How to compare XLS file to json file?

Body:
Hi I have a task to compare some XLS files to json files I have working code but the loop is comparing only first row from xls, does not go to the next one.

def verify_xlsx_file_content_against_json(json, xlsx_path):

    found_configs_ct = 0
    xlsx_reader = XLSXReader()
    data_frame = xlsx_reader.read_xlsx(xlsx_path, "Configuration Set")
    for config in json_definition:
        items_compared = 0
        for item in config["content"]["items"]:
            for index, row in data_frame.iterrows():
                if config["segAlias"] == row["Seg Alias"] and item["itemsOrder"] == row["Items Order"]:
                    found_configs_ct += 1
                    if index == 0:
                        def_platforms = config["platforms"]
                        platforms = ["gp", "ios", "win32", "fb", "amazon"]
                        for platform in platforms:
                            if platform in def_platforms:
                                assert_equal_values(row[convert_def_platform_to_excel_platform_name(platform)], "Y","{" + platform + "} should be True! and is not.")
                            else:
                                assert_equal_values(row[convert_def_platform_to_excel_platform_name(platform)], "N","{" + platform + "} should be False! and is not.")
                        name_from_definition = config["content"]["items"][0]["name"]  # all items have the same name thus index 0 is sufficient
                        assert_equal_values(row["Name"], name_from_definition, "Content name is invalid")
                    Logger.LogInfo(str(item["identifier"]) + ' identifier')
                    Logger.LogInfo(str(row["Identifier"]) + ' Identifier')
                    Logger.LogInfo(str(item["itemsOrder"]) + ' itemsOrder')
                    Logger.LogInfo(str(row["Items Order"]) + ' Items Order')
                    Logger.LogInfo(str(item["dValue"]) + ' dValue')
                    Logger.LogInfo(str(row["D Value, $"]) + ' D Value, $')
                    Logger.LogInfo(str(row["Pack Image"]) + ' PackImage from row  <<<<<<<<<<<<<<<')
                    Logger.LogInfo(str(item["packImage"]) + ' packImage second from item-<<<<<<<<')
                    assert_equal_values(str(item["identifier"]), str(row["Identifier"]), "Identifier is not match!")
                    assert_equal_values(str(item["itemsOrder"]), str(row["Items Order"]), "Items Order is not match!")
                    assert_equal_values(str(item["packImage"]), str(row["Pack Image"]), "packImage is not match!")
                    assert_equal_values(str(item["dValue"]), str(row["D Value, $"]),"dValue  not match!")
                    # assert_equal_values(str(item["remarks"]), str(row["Remarks"]), "Remarks is not match!")
                    items_compared += 1
                    break
        assert_equal_values(items_compared, len(
            config["content"]["items"]), "number of items compared is less than actual items")
    return False
    logging.info("verification done. ---no problems detected--")
    return True  # if code got here, no errors on the way, return True

what I get here is

NFO:root:[2020-02-14 09:33:24.543957] 0 identifier
      INFO:root:[2020-02-14 09:33:24.543957] -1 Identifier
      INFO:root:[2020-02-14 09:33:24.543957] 1 itemsOrder
      INFO:root:[2020-02-14 09:33:24.543957] 1 Items Order
      INFO:root:[2020-02-14 09:33:24.543957] 1.99 dValue
      INFO:root:[2020-02-14 09:33:24.543957] 1.99 D Value, $
      INFO:root:[2020-02-14 09:33:24.544953] 1 identifier
      INFO:root:[2020-02-14 09:33:24.544953] -1 Identifier
      INFO:root:[2020-02-14 09:33:24.544953] 2 itemsOrder
      INFO:root:[2020-02-14 09:33:24.544953] 1 Items Order
      INFO:root:[2020-02-14 09:33:24.544953] 2.99 dValue
      INFO:root:[2020-02-14 09:33:24.544953] 1.99 D Value,
      INFO:root:[2020-02-14 09:33:24.544953] 2 identifier
      INFO:root:[2020-02-14 09:33:24.545949] -1 Identifier

So -1 Identifier is always -1 and should change incrementally (0,1,2... ) like in json file.
How to change this loop to make this code work? and later to assert those files json vs xls

What I did

df = pd.read_excel("download1.xlsx") #xlsx to json
json_from_excel = df.to_json() #json string
print(type(json_from_excel))
print(json_from_excel)
final_dictionary = json.loads(json_from_excel) #dict
print(type(final_dictionary))
print(final_dictionary)

with open('basic.json', 'r') as jason_file:
    data = json.loads(jason_file.read())
    for item in data:
        print(type(item))

and the result is

<class 'str'>
{"Name":{"0":"default_config","1":"default_config","2":"default_config","3":"default_config","4":"default_config","5":"gems1","6":"gems1","7":"gems1","8":"gems1","9":"gems1","10":"gems2","11":"gems2","12":"gems2","13":"gems2","14":"gems2","15":"gems3","16":"gems3","17":"gems3","18":"gems3","19":"gems3"},"Identifier":{"0":11294,"1":11294,"2":11294,"3":11294,"4":11294,"5":11295,"6":11295,"7":11295,"8":11295,"9":11295,"10":11296,"11":11296,"12":11296,"13":11296,"14":11296,"15":11297,"16":11297,"17":11297,"18":11297,"19":11297},"Segment Alias":{"0":"default","1":"default","2":"default","3":"default","4":"default","5":"rhinoQA_1","6":"rhinoQA_1","7":"rhinoQA_1","8":"rhinoQA_1","9":"rhinoQA_1","10":"rhinoQA_2","11":"rhinoQA_2","12":"rhinoQA_2","13":"rhinoQA_2","14":"rhinoQA_2","15":"rhinoQA_3","16":"rhinoQA_3","17":"rhinoQA_3","18":"rhinoQA_3","19":"rhinoQA_3"},"Segment ID":{"0":-1,"1":-1,"2":-1,"3":-1,"4":-1,"5":95365,"6":95365,"7":95365,"8":95365,"9":95365,"10":95366,"11":95366,"12":95366,"13":95366,"14":95366,"15":95367,"16":95367,"17":95367,"18":95367,"19":95367},"GP":{"0":"Y","1":"Y","2":"Y","3":"Y","4":"Y","5":"N","6":"N","7":"N","8":"N","9":"N","10":"N","11":"N","12":"N","13":"N","14":"N","15":"N","16":"N","17":"N","18":"N","19":"N"},"iOS":{"0":"Y","1":"Y","2":"Y","3":"Y","4":"Y","5":"Y","6":"Y","7":"Y","8":"Y","9":"Y","10":"N","11":"N","12":"N","13":"N","14":"N","15":"N","16":"N","17":"N","18":"N","19":"N"},"FB":{"0":"Y","1":"Y","2":"Y","3":"Y","4":"Y","5":"N","6":"N","7":"N","8":"N","9":"N","10":"Y","11":"Y","12":"Y","13":"Y","14":"Y","15":"N","16":"N","17":"N","18":"N","19":"N"},"Amazon":{"0":"Y","1":"Y","2":"Y","3":"Y","4":"Y","5":"N","6":"N","7":"N","8":"N","9":"N","10":"N","11":"N","12":"N","13":"N","14":"N","15":"Y","16":"Y","17":"Y","18":"Y","19":"Y"},"Win32":{"0":"Y","1":"Y","2":"Y","3":"Y","4":"Y","5":"N","6":"N","7":"N","8":"N","9":"N","10":"N","11":"N","12":"N","13":"N","14":"N","15":"N","16":"N","17":"N","18":"N","19":"N"},"Remarks":{"0":"default;A.request cfa for test user and any non existing platform to get default B. request user 520000000101987 (has segment in hbi redis,but not in config), any platform","1":"default;A.request cfa for test user and any non existing platform to get default B. request user 520000000101987 (has segment in hbi redis,but not in config), any platform","2":"default;A.request cfa for test user and any non existing platform to get default B. request user 520000000101987 (has segment in hbi redis,but not in config), any platform","3":"default;A.request cfa for test user and any non existing platform to get default B. request user 520000000101987 (has segment in hbi redis,but not in config), any platform","4":"default;A.request cfa for test user and any non existing platform to get default B. request user 520000000101987 (has segment in hbi redis,but not in config), any platform","5":"*inserted_by_automated_test*","6":"*inserted_by_automated_test*","7":"*inserted_by_automated_test*","8":"*inserted_by_automated_test*","9":"*inserted_by_automated_test*","10":"x1","11":"x1","12":"x1","13":"x1","14":"x1","15":"x3","16":"x3","17":"x3","18":"x3","19":"x3"},"Pack Name":{"0":"test_bingo","1":"test_bingo","2":"test_bingo","3":"test_bingo","4":"test_bingo","5":"test_bingo","6":"test_bingo","7":"test_bingo","8":"test_bingo","9":"test_bingo","10":"test_bingo","11":"test_bingo","12":"test_bingo","13":"test_bingo","14":"test_bingo","15":"test_bingo","16":"test_bingo","17":"test_bingo","18":"test_bingo","19":"test_bingo"},"SKU":{"0":"gems_99","1":"gems_99","2":"gems_99","3":"gems_99","4":"gems_99","5":"gems_99","6":"gems_99","7":"gems_99","8":"gems_99","9":"gems_99","10":"gems_99","11":"gems_99","12":"gems_99","13":"gems_99","14":"gems_99","15":"gems_99","16":"gems_99","17":"gems_99","18":"gems_99","19":"gems_99"},"Sold Item":{"0":"Gems","1":"Gems","2":"Gems","3":"Gems","4":"Gems","5":"Gems","6":"Gems","7":"Gems","8":"Gems","9":"Gems","10":"Gems","11":"Gems","12":"Gems","13":"Gems","14":"Gems","15":"Gems","16":"Gems","17":"Gems","18":"Gems","19":"Gems"},"Items Order":{"0":1,"1":2,"2":3,"3":4,"4":5,"5":1,"6":2,"7":3,"8":4,"9":5,"10":1,"11":2,"12":3,"13":4,"14":5,"15":1,"16":2,"17":3,"18":4,"19":5},"Dollar Value, $":{"0":1.99,"1":2.99,"2":3.99,"3":4.99,"4":5.99,"5":1.99,"6":2.99,"7":3.99,"8":4.99,"9":5.99,"10":1.99,"11":11.99,"12":13.99,"13":14.99,"14":15.99,"15":1.99,"16":2.99,"17":3.99,"18":4.99,"19":5.99},"Item Quantity":{"0":5,"1":15,"2":25,"3":35,"4":45,"5":5,"6":15,"7":25,"8":55,"9":65,"10":5,"11":15,"12":45,"13":55,"14":75,"15":5,"16":15,"17":55,"18":95,"19":85},"Is Best":{"0":"Y","1":"Y","2":"Y","3":"Y","4":"Y","5":"Y","6":"Y","7":"Y","8":"Y","9":"Y","10":"Y","11":"Y","12":"Y","13":"Y","14":"Y","15":"Y","16":"Y","17":"Y","18":"Y","19":"Y"},"Is Popular":{"0":"N","1":"N","2":"N","3":"N","4":"N","5":"N","6":"N","7":"N","8":"N","9":"N","10":"N","11":"N","12":"N","13":"N","14":"N","15":"N","16":"N","17":"N","18":"N","19":"N"},"Footer Type":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1},"Footer Text":{"0":"test_text","1":"test_text","2":"test_text","3":"test_text","4":"test_text","5":"test_text","6":"test_text","7":"test_text","8":"test_text","9":"test_text","10":"test_text","11":"test_text","12":"test_text","13":"test_text","14":"test_text","15":"test_text","16":"test_text","17":"test_text","18":"test_text","19":"test_text"},"Pack Image":{"0":"gems_1.png","1":"gems_2.png","2":"gems_3.png","3":"gems_4.png","4":"gems_5.png","5":"gems_1.png","6":"gems_2.png","7":"gems_3.png","8":"gems_4.png","9":"gems_5.png","10":"gems_1.png","11":"gems_2.png","12":"gems_3.png","13":"gems_4.png","14":"gems_5.png","15":"gems_1.png","16":"gems_2.png","17":"gems_3.png","18":"gems_4.png","19":"gems_5.png"}}
<class 'dict'>
{'Name': {'0': 'default_config', '1': 'default_config', '2': 'default_config', '3': 'default_config', '4': 'default_config', '5': 'gems1', '6': 'gems1', '7': 'gems1', '8': 'gems1', '9': 'gems1', '10': 'gems2', '11': 'gems2', '12': 'gems2', '13': 'gems2', '14': 'gems2', '15': 'gems3', '16': 'gems3', '17': 'gems3', '18': 'gems3', '19': 'gems3'}, 'Identifier': {'0': 11294, '1': 11294, '2': 11294, '3': 11294, '4': 11294, '5': 11295, '6': 11295, '7': 11295, '8': 11295, '9': 11295, '10': 11296, '11': 11296, '12': 11296, '13': 11296, '14': 11296, '15': 11297, '16': 11297, '17': 11297, '18': 11297, '19': 11297}, 'Segment Alias': {'0': 'default', '1': 'default', '2': 'default', '3': 'default', '4': 'default', '5': 'rhinoQA_1', '6': 'rhinoQA_1', '7': 'rhinoQA_1', '8': 'rhinoQA_1', '9': 'rhinoQA_1', '10': 'rhinoQA_2', '11': 'rhinoQA_2', '12': 'rhinoQA_2', '13': 'rhinoQA_2', '14': 'rhinoQA_2', '15': 'rhinoQA_3', '16': 'rhinoQA_3', '17': 'rhinoQA_3', '18': 'rhinoQA_3', '19': 'rhinoQA_3'}, 'Segment ID': {'0': -1, '1': -1, '2': -1, '3': -1, '4': -1, '5': 95365, '6': 95365, '7': 95365, '8': 95365, '9': 95365, '10': 95366, '11': 95366, '12': 95366, '13': 95366, '14': 95366, '15': 95367, '16': 95367, '17': 95367, '18': 95367, '19': 95367}, 'GP': {'0': 'Y', '1': 'Y', '2': 'Y', '3': 'Y', '4': 'Y', '5': 'N', '6': 'N', '7': 'N', '8': 'N', '9': 'N', '10': 'N', '11': 'N', '12': 'N', '13': 'N', '14': 'N', '15': 'N', '16': 'N', '17': 'N', '18': 'N', '19': 'N'}, 'iOS': {'0': 'Y', '1': 'Y', '2': 'Y', '3': 'Y', '4': 'Y', '5': 'Y', '6': 'Y', '7': 'Y', '8': 'Y', '9': 'Y', '10': 'N', '11': 'N', '12': 'N', '13': 'N', '14': 'N', '15': 'N', '16': 'N', '17': 'N', '18': 'N', '19': 'N'}, 'FB': {'0': 'Y', '1': 'Y', '2': 'Y', '3': 'Y', '4': 'Y', '5': 'N', '6': 'N', '7': 'N', '8': 'N', '9': 'N', '10': 'Y', '11': 'Y', '12': 'Y', '13': 'Y', '14': 'Y', '15': 'N', '16': 'N', '17': 'N', '18': 'N', '19': 'N'}, 'Amazon': {'0': 'Y', '1': 'Y', '2': 'Y', '3': 'Y', '4': 'Y', '5': 'N', '6': 'N', '7': 'N', '8': 'N', '9': 'N', '10': 'N', '11': 'N', '12': 'N', '13': 'N', '14': 'N', '15': 'Y', '16': 'Y', '17': 'Y', '18': 'Y', '19': 'Y'}, 'Win32': {'0': 'Y', '1': 'Y', '2': 'Y', '3': 'Y', '4': 'Y', '5': 'N', '6': 'N', '7': 'N', '8': 'N', '9': 'N', '10': 'N', '11': 'N', '12': 'N', '13': 'N', '14': 'N', '15': 'N', '16': 'N', '17': 'N', '18': 'N', '19': 'N'}, 'Remarks': {'0': 'default;A.request cfa for test user and any non existing platform to get default B. request user 520000000101987 (has segment in hbi redis,but not in config), any platform', '1': 'default;A.request cfa for test user and any non existing platform to get default B. request user 520000000101987 (has segment in hbi redis,but not in config), any platform', '2': 'default;A.request cfa for test user and any non existing platform to get default B. request user 520000000101987 (has segment in hbi redis,but not in config), any platform', '3': 'default;A.request cfa for test user and any non existing platform to get default B. request user 520000000101987 (has segment in hbi redis,but not in config), any platform', '4': 'default;A.request cfa for test user and any non existing platform to get default B. request user 520000000101987 (has segment in hbi redis,but not in config), any platform', '5': '*inserted_by_automated_test*', '6': '*inserted_by_automated_test*', '7': '*inserted_by_automated_test*', '8': '*inserted_by_automated_test*', '9': '*inserted_by_automated_test*', '10': 'x1', '11': 'x1', '12': 'x1', '13': 'x1', '14': 'x1', '15': 'x3', '16': 'x3', '17': 'x3', '18': 'x3', '19': 'x3'}, 'Pack Name': {'0': 'test_bingo', '1': 'test_bingo', '2': 'test_bingo', '3': 'test_bingo', '4': 'test_bingo', '5': 'test_bingo', '6': 'test_bingo', '7': 'test_bingo', '8': 'test_bingo', '9': 'test_bingo', '10': 'test_bingo', '11': 'test_bingo', '12': 'test_bingo', '13': 'test_bingo', '14': 'test_bingo', '15': 'test_bingo', '16': 'test_bingo', '17': 'test_bingo', '18': 'test_bingo', '19': 'test_bingo'}, 'SKU': {'0': 'gems_99', '1': 'gems_99', '2': 'gems_99', '3': 'gems_99', '4': 'gems_99', '5': 'gems_99', '6': 'gems_99', '7': 'gems_99', '8': 'gems_99', '9': 'gems_99', '10': 'gems_99', '11': 'gems_99', '12': 'gems_99', '13': 'gems_99', '14': 'gems_99', '15': 'gems_99', '16': 'gems_99', '17': 'gems_99', '18': 'gems_99', '19': 'gems_99'}, 'Sold Item': {'0': 'Gems', '1': 'Gems', '2': 'Gems', '3': 'Gems', '4': 'Gems', '5': 'Gems', '6': 'Gems', '7': 'Gems', '8': 'Gems', '9': 'Gems', '10': 'Gems', '11': 'Gems', '12': 'Gems', '13': 'Gems', '14': 'Gems', '15': 'Gems', '16': 'Gems', '17': 'Gems', '18': 'Gems', '19': 'Gems'}, 'Items Order': {'0': 1, '1': 2, '2': 3, '3': 4, '4': 5, '5': 1, '6': 2, '7': 3, '8': 4, '9': 5, '10': 1, '11': 2, '12': 3, '13': 4, '14': 5, '15': 1, '16': 2, '17': 3, '18': 4, '19': 5}, 'Dollar Value, $': {'0': 1.99, '1': 2.99, '2': 3.99, '3': 4.99, '4': 5.99, '5': 1.99, '6': 2.99, '7': 3.99, '8': 4.99, '9': 5.99, '10': 1.99, '11': 11.99, '12': 13.99, '13': 14.99, '14': 15.99, '15': 1.99, '16': 2.99, '17': 3.99, '18': 4.99, '19': 5.99}, 'Item Quantity': {'0': 5, '1': 15, '2': 25, '3': 35, '4': 45, '5': 5, '6': 15, '7': 25, '8': 55, '9': 65, '10': 5, '11': 15, '12': 45, '13': 55, '14': 75, '15': 5, '16': 15, '17': 55, '18': 95, '19': 85}, 'Is Best': {'0': 'Y', '1': 'Y', '2': 'Y', '3': 'Y', '4': 'Y', '5': 'Y', '6': 'Y', '7': 'Y', '8': 'Y', '9': 'Y', '10': 'Y', '11': 'Y', '12': 'Y', '13': 'Y', '14': 'Y', '15': 'Y', '16': 'Y', '17': 'Y', '18': 'Y', '19': 'Y'}, 'Is Popular': {'0': 'N', '1': 'N', '2': 'N', '3': 'N', '4': 'N', '5': 'N', '6': 'N', '7': 'N', '8': 'N', '9': 'N', '10': 'N', '11': 'N', '12': 'N', '13': 'N', '14': 'N', '15': 'N', '16': 'N', '17': 'N', '18': 'N', '19': 'N'}, 'Footer Type': {'0': 1, '1': 1, '2': 1, '3': 1, '4': 1, '5': 1, '6': 1, '7': 1, '8': 1, '9': 1, '10': 1, '11': 1, '12': 1, '13': 1, '14': 1, '15': 1, '16': 1, '17': 1, '18': 1, '19': 1}, 'Footer Text': {'0': 'test_text', '1': 'test_text', '2': 'test_text', '3': 'test_text', '4': 'test_text', '5': 'test_text', '6': 'test_text', '7': 'test_text', '8': 'test_text', '9': 'test_text', '10': 'test_text', '11': 'test_text', '12': 'test_text', '13': 'test_text', '14': 'test_text', '15': 'test_text', '16': 'test_text', '17': 'test_text', '18': 'test_text', '19': 'test_text'}, 'Pack Image': {'0': 'gems_1.png', '1': 'gems_2.png', '2': 'gems_3.png', '3': 'gems_4.png', '4': 'gems_5.png', '5': 'gems_1.png', '6': 'gems_2.png', '7': 'gems_3.png', '8': 'gems_4.png', '9': 'gems_5.png', '10': 'gems_1.png', '11': 'gems_2.png', '12': 'gems_3.png', '13': 'gems_4.png', '14': 'gems_5.png', '15': 'gems_1.png', '16': 'gems_2.png', '17': 'gems_3.png', '18': 'gems_4.png', '19': 'gems_5.png'}}
{'id': 0, 'segmentAlias': 'default', 'userIds': [-1], 'platforms': ['gp'], 'content': {'items': [{'name': 'default_config', 'identifier': 0, 'itemsOrder': 1, 'dollarValue': 1.99, 'remarks': 'default!', 'itemsQuantity': 5, 'is_best': 'Y', 'is_popular': 'N', 'packName': 'test_bingo', 'footerType': 1, 'footerText': 'test_text', 'soldItem': 'Gems', 'packImage': 'gems_1.png', 'SKU': 'gems_99'}, {'name': 'default_config', 'identifier': 1, 'itemsOrder': 2, 'dollarValue': 2.99, 'remarks': 'default!', 'itemsQuantity': 15, 'is_best': 'Y', 'is_popular': 'N', 'packName': 'test_bingo', 'footerType': 1, 'footerText': 'test_text', 'soldItem': 'Gems', 'packImage': 'gems_2.png', 'SKU': 'gems_99'}, {'name': 'default_config', 'identifier': 2, 'itemsOrder': 3, 'dollarValue': 3.99, 'remarks': 'default!', 'itemsQuantity': 25, 'is_best': 'Y', 'is_popular': 'N', 'packName': 'test_bingo', 'footerType': 1, 'footerText': 'test_text', 'soldItem': 'Gems', 'packImage': 'gems_3.png', 'SKU': 'gems_99'}, {'name': 'default_config', 'identifier': 3, 'itemsOrder': 4, 'dollarValue': 4.99, 'remarks': 'default!', 'itemsQuantity': 35, 'is_best': 'Y', 'is_popular': 'N', 'packName': 'test_bingo', 'footerType': 1, 'footerText': 'test_text', 'soldItem': 'Gems', 'packImage': 'gems_4.png', 'SKU': 'gems_99'}, {'name': 'default_config', 'identifier': 4, 'itemsOrder': 5, 'dollarValue': 5.99, 'remarks': 'default!', 'itemsQuantity': 45, 'is_best': 'Y', 'is_popular': 'N', 'packName': 'test_bingo', 'footerType': 1, 'footerText': 'test_text', 'soldItem': 'Gems', 'packImage': 'gems_5.png', 'SKU': 'gems_99'}]}}
<class 'dict'>
{'id': 1, 'segmentAlias': 's1', 'userIds': [-1], 'platforms': ['ios'], 'content': {'items': [{'name': 'gems1', 'identifier': 0, 'itemsOrder': 1, 'dollarValue': 1.99, 'remarks': 'x', 'itemsQuantity': 5,

I cannot compare those dicts

Body:
You will need to read the excel file and convert it to json with pandas. Also check in which format is your json file when converting from pandas. Maybe you need to change the orientation.

df = pd.read_excel(xlsx, sheet_name=sheet)

json_from_excel = df.to_json(orient='records')

Next you will need to order your json data here is an example function.

def ordered(obj):
    if isinstance(obj, dict):
        return sorted((k, ordered(v)) for k, v in obj.items())
    if isinstance(obj, list):
        return sorted(ordered(x) for x in obj)
    else:
        return obj

And finally you can make the compare.

if ordered(json_from_excel) == ordered(json_data):
   #do something


问:
How to alter a API response with Javascript
I wrote this little app that takes in a set of starwars characters and returns images in an array.

```<code>const app = require('express')();
const fetch = require('node-fetch');
const imageSearch = require('image-search-google');
const bodyParser = require('body-parser')

var urlencodedParser = bodyParser.urlencoded({ extended: true })
app.use(bodyParser.json())

const options = {page:1};

const getImages = (keywords) =>
 Promise.all(keywords.map(keyword => client.search(`${keyword} Wookieepedia`, options)))
 .then(data => firstResult = data.map(result => result[0].url));

 const fun = async () => {
     const res = await getImages(['yoda' , 'luke skywalker' , 'darth vader']);
     console.log(res);
 }

 fun()
</code>```

The result of the above code looks like this :

```<code>[ 'https://vignette.wikia.nocookie.net/starwars/images/d/d6/Yoda_SWSB.png/revision/latest?cb=20150206140125',
  'https://vignette.wikia.nocookie.net/starwars/images/d/d9/Luke-rotjpromo.jpg/revision/latest?cb=20091030151422',
  'https://vignette.wikia.nocookie.net/starwars/images/a/a3/ANOVOS_Darth_Vader_1.png/revision/latest?cb=20150128225029' ]
</code>```

But i would like a result where i can know which image belongs to which keyword.  Maybe a format like this or something similar :

```<code>[{<keyword> : <url>}]
</code>```

I tried this :

```<code>const getImages = (keywords) =>
 Promise.all(keywords.map(keyword => {return { [keyword] : [client.search(`${keyword} Wookieepedia`, options)]}    } ))
 .then(data => firstResult = data.map(result => result));

 const fun = async () => {
     const res = await getImages(['yoda' , 'luke skywalker' , 'darth vader']);
     console.log(res);
 }

 fun()
</code>```

Results were close but not good :

```<code>[ { yoda: [ [Promise] ] },
  { 'luke skywalker': [ [Promise] ] },
  { 'darth vader': [ [Promise] ] } ]
</code>```

答:
client.search returns a Promise. It can be awaited inside the mapping function if you make the mapping function async.

const getImages = (keywords) =>
    Promise.all(keywords.map(async keyword => {
        return {[keyword]: await client.search(`${keyword} Wookieepedia`, options)}
    }));
```

Body:
I wrote this little app that takes in a set of starwars characters and returns images in an array.

const app = require('express')();
const fetch = require('node-fetch');
const imageSearch = require('image-search-google');
const bodyParser = require('body-parser')

var urlencodedParser = bodyParser.urlencoded({ extended: true })
app.use(bodyParser.json())

const options = {page:1};

const getImages = (keywords) =>
 Promise.all(keywords.map(keyword => client.search(`${keyword} Wookieepedia`, options)))
 .then(data => firstResult = data.map(result => result[0].url));

 const fun = async () => {
     const res = await getImages(['yoda' , 'luke skywalker' , 'darth vader']);
     console.log(res);
 }

 fun()

The result of the above code looks like this :

[ 'https://vignette.wikia.nocookie.net/starwars/images/d/d6/Yoda_SWSB.png/revision/latest?cb=20150206140125',
  'https://vignette.wikia.nocookie.net/starwars/images/d/d9/Luke-rotjpromo.jpg/revision/latest?cb=20091030151422',
  'https://vignette.wikia.nocookie.net/starwars/images/a/a3/ANOVOS_Darth_Vader_1.png/revision/latest?cb=20150128225029' ]

But i would like a result where i can know which image belongs to which keyword.  Maybe a format like this or something similar :

[{<keyword> : <url>}]

I tried this :

const getImages = (keywords) =>
 Promise.all(keywords.map(keyword => {return { [keyword] : [client.search(`${keyword} Wookieepedia`, options)]}    } ))
 .then(data => firstResult = data.map(result => result));

 const fun = async () => {
     const res = await getImages(['yoda' , 'luke skywalker' , 'darth vader']);
     console.log(res);
 }

 fun()

Results were close but not good :

[ { yoda: [ [Promise] ] },
  { 'luke skywalker': [ [Promise] ] },
  { 'darth vader': [ [Promise] ] } ]


问:
VueJS: dynamically set component's methods
I have a SPA application with single page components; I want to import certain methods for the component based on my route's name. How can I achieve that in Vue? Something like:</p>

```<code><template>
    <div>
        <div v-for="foo in customMethod()">{{foo.bar}}</div>
    </div>
</template>

<script>
export default {
    methods: {},

    mounted: function() {
        switch(this.$route.name) {
            case "route.name":
                this.methods = require('./external-script.js');
                break;
            case "another.route.name":
                this.methods = require('./another-external-script.js');
                break;
        }
    }
}

</script>
</code>```

答: This description seems like a problem which Strategy design pattern can solve, because you need one different behavior according to the route name. Check out this post. If it's not your intention, you can try the Vue dynamic components.</p>

Body:
I have a SPA application with single page components; I want to import certain methods for the component based on my route's name. How can I achieve that in Vue? Something like:

<template>

{{foo.bar}}

</template>


问:
main title in plot consisting of pictures is out of range
I ma trying to make plot consisting of 6 images, each with it's own title and above all have main title for whole plot. When I try to create it it is visible in inline graphics, but when saved as png it is off the plot. I have tried making figure vertically bigger, but it did not help

Visible in line:

When saved to file - it lacks main title:

Data to test:

1) creating temporary photo to work with 0 in my real problem this are diffrent images

```<code>import pandas as pd
import os
import cv2
import matplotlib.pyplot as plt

Test_df = pd.DataFrame(data = {'x': [1, 2, 3, 4], \
                               'y' : [1, 2, 3, 4]})

#creating fake photo
plt.plot(Test_df['x'], Test_df['y'], "o")
plt.savefig('test.png')

#read as picture
tmp = cv2.imread('test.png')
</code>```

2) creating final plot

```<code>#creating desired plot
f, axarr = plt.subplots(2,3, figsize=(7.5,5))

# add main title
f.text(0, 1, 'main title',
         fontsize=15, fontweight='black', color = '#333F4B')

for i in range(1,3):
    for j in range(1,4):
        axarr[i - 1, j - 1].imshow(tmp)
        axarr[i - 1, j - 1].set_axis_off()
        axarr[i - 1, j - 1].axis("tight")  # gets rid of white border
        axarr[i - 1, j - 1].axis("image") # square up the image instead of filling the "figure" space
        title = str(i + j)
        axarr[i - 1, j - 1].set_title(title, fontsize = 8, color = '#333F4B')
        axarr[i - 1, j - 1].set_facecolor('b')

plt.tight_layout()

plt.savefig('result.png')
</code>```

EDIT

It worked ok, when used subtitle and removed plt.tight_layout()

答:
Since you are using it as a text right now, it somehow is getting clipped due to the tight_layout while saving. Your code will work fine if instead of 1 for the y-coordinate, you use something up to 0.97. To test that, try also f.text(0, 0.97, 'main title', ....

I would recommend to use the in-built function suptitle for this task.

```<code>f.suptitle('main title', x=0, y=1, fontsize=15,
           fontweight='black', color = '#333F4B')
plt.tight_layout()
</code>```

Body:
I ma trying to make plot consisting of 6 images, each with it's own title and above all have main title for whole plot. When I try to create it it is visible in inline graphics, but when saved as png it is off the plot. I have tried making figure vertically bigger, but it did not help

Visible in line:

When saved to file - it lacks main title:

Data to test:

1) creating temporary photo to work with 0 in my real problem this are diffrent images

import pandas as pd
import os
import cv2
import matplotlib.pyplot as plt

Test_df = pd.DataFrame(data = {'x': [1, 2, 3, 4], \
                               'y' : [1, 2, 3, 4]})

#creating fake photo
plt.plot(Test_df['x'], Test_df['y'], "o")
plt.savefig('test.png')

#read as picture
tmp = cv2.imread('test.png')

2) creating final plot

#creating desired plot
f, axarr = plt.subplots(2,3, figsize=(7.5,5))

# add main title
f.text(0, 1, 'main title',
         fontsize=15, fontweight='black', color = '#333F4B')

for i in range(1,3):
    for j in range(1,4):
        axarr[i - 1, j - 1].imshow(tmp)
        axarr[i - 1, j - 1].set_axis_off()
        axarr[i - 1, j - 1].axis("tight")  # gets rid of white border
        axarr[i - 1, j - 1].axis("image") # square up the image instead of filling the "figure" space
        title = str(i + j)
        axarr[i - 1, j - 1].set_title(title, fontsize = 8, color = '#333F4B')
        axarr[i - 1, j - 1].set_facecolor('b')

plt.tight_layout()

plt.savefig('result.png')

EDIT

It worked ok, when used subtitle and removed plt.tight_layout()

Body:
Since you are using it as a text right now, it somehow is getting clipped due to the tight_layout while saving. Your code will work fine if instead of 1 for the y-coordinate, you use something up to 0.97. To test that, try also f.text(0, 0.97, 'main title', ....

I would recommend to use the in-built function suptitle for this task.

f.suptitle('main title', x=0, y=1, fontsize=15,
           fontweight='black', color = '#333F4B')
plt.tight_layout()


问:
XML and Special characters & different closing tags
Ok.. so I have an excel spread sheet. I need to build a schema that will suite the columns within the sheet. But the columns titles contain HTML code. Is there a XML editor that can assist in this or can I do this freehand?

```<code><meta name="title" content="Test Page"/>
<meta name="dcterms.title" content="Test Page" />
<meta name="dcterms.creator.CHIN" content="All about my test page..blah blah blah"/>
<meta name="dcterms.creator.org" content="Test Guy"/>
<meta name="dcterms.creator.ind" content="TG"/>
<meta name="dcterms.created" scheme="W3CDTF" content=""/>
<meta name="dcterms.issued" scheme="W3CDTF" content="2010-11-13"/>
<meta name="dcterms.modified" scheme="W3CDTF" content=""/>
<meta name="dcterms.language" scheme="ISO639-2/T" content="eng" />
</code>```

The name of each column is within tags... whats the solution to make tis work.. any ideas?

答:
If the title, dcterms.* are the tag names, you're in the clear.

XML tag names can contain ., just not start with it.

Edit: As an alternative, you could tree out:

```<code><dcterms>
  <dcterm>
    <title>Test Page</title>
    <creator>
      <CHIN>All about my test page..blah blah blah</CHIN>
      <org>Test Guy</org>
      <ind>TG</ind>
    </creator>
    <created>2010-11-13</created>
    <!-- ... -->
  </dcterm>
  <dcterm>
    <!-- ... -->
  </dcterm>
</dcterms>
</code>```

Depending on your setup, this may or may not end up as being easier to parse and, generally, deal with.

Body:
Ok.. so I have an excel spread sheet. I need to build a schema that will suite the columns within the sheet. But the columns titles contain HTML code. Is there a XML editor that can assist in this or can I do this freehand?

<meta name="title" content="Test Page"/>
<meta name="dcterms.title" content="Test Page" />
<meta name="dcterms.creator.CHIN" content="All about my test page..blah blah blah"/>
<meta name="dcterms.creator.org" content="Test Guy"/>
<meta name="dcterms.creator.ind" content="TG"/>
<meta name="dcterms.created" scheme="W3CDTF" content=""/>
<meta name="dcterms.issued" scheme="W3CDTF" content="2010-11-13"/>
<meta name="dcterms.modified" scheme="W3CDTF" content=""/>
<meta name="dcterms.language" scheme="ISO639-2/T" content="eng" />

The name of each column is within tags... whats the solution to make tis work.. any ideas?

Body:
If the title, dcterms.* are the tag names, you're in the clear.

XML tag names can contain ., just not start with it.

Edit: As an alternative, you could tree out:

<dcterms>
  <dcterm>
    <title>Test Page</title>
    <creator>
      <CHIN>All about my test page..blah blah blah</CHIN>
      <org>Test Guy</org>
      <ind>TG</ind>
    </creator>
    <created>2010-11-13</created>
    <!-- ... -->
  </dcterm>
  <dcterm>
    <!-- ... -->
  </dcterm>
</dcterms>

Depending on your setup, this may or may not end up as being easier to parse and, generally, deal with.


问:
How to apply several functions on every possible row combinations within a dataframe in R?
I've got a dataframe with coordinates (lon, lat)

```<code>    lon <- list(505997.627175236, 505997.627175236, 505997.627175236, 505997.627175236)
    lon <- do.call(rbind.data.frame, lon)

    lat <- list(7941821.025438220, 7941821.025438220, 7941821.025438220, 7941821.025438220)
    lat <- do.call(rbind.data.frame, lat)

    coord <- cbind(lon, lat)
    colnames(coord) <- c("lon", "lat")
</code>```

I'm trying to calculate the euclidian distance and the angle between all the possible row combinations within the dataframe.

```<code>     lon   lat       apply function on every possible combinations such as v1-v2, v1-v3, v1-v4,
v1   x1    y1        v2-v3 and so on...
v2   x2    y2
v3   x3    y3        here are the two functions applied beetween v1 and v2 :
v4   x4    y4        **euclidian distance**    sqrt((x1-x2)^2 + (y1-y2)^2)
                     **angle**                 atan2((y1-y2),(x1-x2))*(180/pi)
</code>```

How to apply several functions on every possible row combinations and get the results in respective lists ? My goal is to use these calculations at every iteration whatever the number of row in input.

Thanks in advance for your answers and sorry if the question seems silly. I've looked at so many posts but couldn't find a solution that I could understand and replicate.

Body:
I've got a dataframe with coordinates (lon, lat)

    lon <- list(505997.627175236, 505997.627175236, 505997.627175236, 505997.627175236)
    lon <- do.call(rbind.data.frame, lon)

    lat <- list(7941821.025438220, 7941821.025438220, 7941821.025438220, 7941821.025438220)
    lat <- do.call(rbind.data.frame, lat)

    coord <- cbind(lon, lat)
    colnames(coord) <- c("lon", "lat")

I'm trying to calculate the euclidian distance and the angle between all the possible row combinations within the dataframe.

     lon   lat       apply function on every possible combinations such as v1-v2, v1-v3, v1-v4,
v1   x1    y1        v2-v3 and so on...
v2   x2    y2
v3   x3    y3        here are the two functions applied beetween v1 and v2 :
v4   x4    y4        **euclidian distance**    sqrt((x1-x2)^2 + (y1-y2)^2)
                     **angle**                 atan2((y1-y2),(x1-x2))*(180/pi)

How to apply several functions on every possible row combinations and get the results in respective lists ? My goal is to use these calculations at every iteration whatever the number of row in input.

Thanks in advance for your answers and sorry if the question seems silly. I've looked at so many posts but couldn't find a solution that I could understand and replicate.

Body:
# two vectors (I changed them a little bit)
lon <- c(505997.627175236, 505597.627175236, 515997.627175236, 505297.627175236)
lat <- c(7941821.025438220, 7945821.025438220, 7141821.025438220, 7921821.025438220)

# a function for the euclidean distance
eDistance <- function(x1, x2, y1, y2) sqrt((x1-x2)^2 + (y1-y2)^2)

# now we create a dataframe...
df <- data.frame(lon, lat) %>%
    mutate(joinIndex = 1:nrow(.)) # and we add an index column

# ...that looks like this
#        lon     lat joinIndex
# 1 505997.6 7941821         1
# 2 505597.6 7945821         2
# 3 515997.6 7141821         3
# 4 505297.6 7921821         4

# create all combinations of the join indeces
df_combinations <- expand.grid(1:nrow(df), 1:nrow(df))

#    Var1 Var2
# 1     1    1
# 2     2    1
# 3     3    1
# 4     4    1
# 5     1    2
# 6     2    2
# 7     3    2
# 8     4    2
# 9     1    3
# 10    2    3
# 11    3    3
# 12    4    3
# 13    1    4
# 14    2    4
# 15    3    4
# 16    4    4

# and join our dataframe first on one index then on the other
df_final <- df_combinations %>%
    left_join(df, by = c("Var1" = "joinIndex")) %>%
    left_join(df, by = c("Var2" = "joinIndex"))

# and then finally calculate the euclidean distance
df_final %>%
    mutate(distance = eDistance(lon.x, lon.y, lat.x, lat.y))

   Var1 Var2    lon.x   lat.x    lon.y   lat.y  distance
1     1    1 505997.6 7941821 505997.6 7941821      0.00
2     2    1 505597.6 7945821 505997.6 7941821   4019.95
3     3    1 515997.6 7141821 505997.6 7941821 800062.50
4     4    1 505297.6 7921821 505997.6 7941821  20012.25
5     1    2 505997.6 7941821 505597.6 7945821   4019.95
6     2    2 505597.6 7945821 505597.6 7945821      0.00
7     3    2 515997.6 7141821 505597.6 7945821 804067.26
8     4    2 505297.6 7921821 505597.6 7945821  24001.87
9     1    3 505997.6 7941821 515997.6 7141821 800062.50
10    2    3 505597.6 7945821 515997.6 7141821 804067.26
11    3    3 515997.6 7141821 515997.6 7141821      0.00
12    4    3 505297.6 7921821 515997.6 7141821 780073.39
13    1    4 505997.6 7941821 505297.6 7921821  20012.25
14    2    4 505597.6 7945821 505297.6 7921821  24001.87
15    3    4 515997.6 7141821 505297.6 7921821 780073.39
16    4    4 505297.6 7921821 505297.6 7921821      0.00


答:
Base R function combn generates the combinations of a vector's elements taken m at a time and it can, optionally, apply a function FUN to those combinations. Since the input data is a "data.frame", I will combine the rownames 2 by 2.

```<code>euclidean <- function(k){
  f <- function(x, y) sqrt((x[1] - y[1])^2 + (x[2] - y[2])^2)
  x <- unlist(coord[k[1], 1:2])
  y <- unlist(coord[k[2], 1:2])
  f(x, y)
}

angle <- function(k){
  f <- function(x, y) atan2(x[2] - y[2], x[1] - y[1])*(180/pi)
  x <- unlist(coord[k[1], 1:2])
  y <- unlist(coord[k[2], 1:2])
  f(x, y)
}

combn(rownames(coord), 2, euclidean)
#[1]   4019.95 800062.50  20012.25 804067.26  24001.87 780073.39

combn(rownames(coord), 2, angle)
#[1] -84.28941  90.71616  87.99547  90.74110  89.28384 -89.21407
</code>```

Data.

This is the data in the OP's answer but without the id column.

```<code>lon <- c(505997.627175236, 505597.627175236,
         515997.627175236, 505297.627175236)
lat <- c(7941821.025438220, 7945821.025438220,
         7141821.025438220, 7921821.025438220)
coord <- data.frame(lon, lat)
</code>```

Title: How to apply several functions on every possible row combinations within a dataframe in R?

Body:
Base R function combn generates the combinations of a vector's elements taken m at a time and it can, optionally, apply a function FUN to those combinations. Since the input data is a "data.frame", I will combine the rownames 2 by 2.

euclidean <- function(k){
  f <- function(x, y) sqrt((x[1] - y[1])^2 + (x[2] - y[2])^2)
  x <- unlist(coord[k[1], 1:2])
  y <- unlist(coord[k[2], 1:2])
  f(x, y)
}

angle <- function(k){
  f <- function(x, y) atan2(x[2] - y[2], x[1] - y[1])*(180/pi)
  x <- unlist(coord[k[1], 1:2])
  y <- unlist(coord[k[2], 1:2])
  f(x, y)
}

combn(rownames(coord), 2, euclidean)
#[1]   4019.95 800062.50  20012.25 804067.26  24001.87 780073.39

combn(rownames(coord), 2, angle)
#[1] -84.28941  90.71616  87.99547  90.74110  89.28384 -89.21407

Data.

This is the data in the OP's answer but without the id column.

lon <- c(505997.627175236, 505597.627175236,
         515997.627175236, 505297.627175236)
lat <- c(7941821.025438220, 7945821.025438220,
         7141821.025438220, 7921821.025438220)
coord <- data.frame(lon, lat)


问:
favicon not working in angular application
This is below code which is for a custom favicon

```<code> <link rel="shortcut icon" sizes="16x16" href="favicon-16x16.png" type="image/png" />
</code>```

in angular.cli

```<code>"assets": [
        "assets",
        "favicon-16x16.png"
      ],
</code>```

It's working for this URL(main menu) : http://localhost:4200/maintenance

But  it's not working for this URL(Sub Menu): http://localhost:4200/maintenance/colors

EDIT:

Also it's not working with full favicon URL href="../src/favicon-16x16.png"

Folder structure :

I have tried with putting all type of URL's from my old question : Different between ./ , ../ , ../../ , ~/ on file path(URL) in asp.net

But it doesn't help me.

答:
Add image inside assets folder and update below path in index.html</p>

```<code><link rel="icon" href="assets/favicon.png" type="image/png">
</code>```

Body:
This is below code which is for a custom favicon

 <link rel="shortcut icon" sizes="16x16" href="favicon-16x16.png" type="image/png" />

in angular.cli

"assets": [
        "assets",
        "favicon-16x16.png"
      ],

It's working for this URL(main menu) : http://localhost:4200/maintenance

But  it's not working for this URL(Sub Menu): http://localhost:4200/maintenance/colors

EDIT:

Also it's not working with full favicon URL href="../src/favicon-16x16.png"

Folder structure :

I have tried with putting all type of URL's from my old question : Different between ./ , ../ , ../../ , ~/ on file path(URL) in asp.net

But it doesn't help me.

Body:
Add image inside assets folder and update below path in index.html

<link rel="icon" href="assets/favicon.png" type="image/png">


问:
Sumproduct & arrayformula
I have two sheets, both have rows of data where one row represents a specific date in chronological order.

The sumproduct only needs to be made on the latest date (date in below example is in column A).

I set this up with:

```<code>=sum(ARRAYFORMULA((A3:A1000=max(A3:A1000))
</code>```

So assuming that I need to sumproduct the two sheets on this specific row, I can't seem to figure out how to append the sumproduct formula into the arrayformula base.

The sumproduct is pretty basic. Assuming that row 12 is the latest date, I need Sheet 1 Cell B12 to multiply by Sheet 2 Cell B12, then sheet 1 cell C12 to multiply by Sheet 2 Cell C12 and so on.

答:
sumproduct of whole last row of sheet1 with the same row from sheet2:

```<code>=ARRAYFORMULA(SUMPRODUCT(
 INDIRECT("Sheet1!"&ADDRESS(MAX(IF(Sheet1!A:A="",,ROW(Sheet1!A:A))), 2)&
 ":"&MAX(IF(Sheet1!A:A="",,ROW(Sheet1!A:A)))),
 INDIRECT("Sheet2!"&ADDRESS(MAX(IF(Sheet1!A:A="",,ROW(Sheet1!A:A))), 2)&
 ":"&MAX(IF(Sheet1!A:A="",,ROW(Sheet1!A:A))))))
</code>```

Title: Sumproduct & arrayformula

Body:
I have two sheets, both have rows of data where one row represents a specific date in chronological order.

The sumproduct only needs to be made on the latest date (date in below example is in column A).

I set this up with:

=sum(ARRAYFORMULA((A3:A1000=max(A3:A1000))

So assuming that I need to sumproduct the two sheets on this specific row, I can't seem to figure out how to append the sumproduct formula into the arrayformula base.

The sumproduct is pretty basic. Assuming that row 12 is the latest date, I need Sheet 1 Cell B12 to multiply by Sheet 2 Cell B12, then sheet 1 cell C12 to multiply by Sheet 2 Cell C12 and so on.

Body:
sumproduct of whole last row of sheet1 with the same row from sheet2:

=ARRAYFORMULA(SUMPRODUCT(
 INDIRECT("Sheet1!"&ADDRESS(MAX(IF(Sheet1!A:A="",,ROW(Sheet1!A:A))), 2)&
 ":"&MAX(IF(Sheet1!A:A="",,ROW(Sheet1!A:A)))),
 INDIRECT("Sheet2!"&ADDRESS(MAX(IF(Sheet1!A:A="",,ROW(Sheet1!A:A))), 2)&
 ":"&MAX(IF(Sheet1!A:A="",,ROW(Sheet1!A:A))))))


问:
jQuery Mobile .NET form breaks android
Im developing a site using jquery mobile and it has been reported that dropdowns are not working in android for pages that are rendered through the .NET cms.

I've narrowed down the issue to be the form element that wraps all content on a .NET page. I've tested both with and without the form and the form is definitely the culprit. The with form vers works on iPhone and other smartphones that were tested, so this is specific to Android.

Anyone who has run into this and has some insight to share would be greatly appreciated.

答:
I received a response (https://github.com/jquery/jquery-mobile/issues/1625#comment_1154114) from a maintainer of the jqm project on the bug I posted, that they will not be attempting to resolve this on their end, which is just as well as it really needs to be done on the .NET site. </p>

<p>We ended up solving this by adding the form element just inside the data-role=page element which made the android devices in question happy. </p>

Title: jQuery Mobile .NET form breaks android

Body:
I received a response (https://github.com/jquery/jquery-mobile/issues/1625#comment_1154114) from a maintainer of the jqm project on the bug I posted, that they will not be attempting to resolve this on their end, which is just as well as it really needs to be done on the .NET site.

We ended up solving this by adding the form element just inside the data-role=page element which made the android devices in question happy.


问:
libQt5XcbQpa.so.5: undefined symbol: FT_Property_Set
I get this error when I try to run wkhtmltopdf command from my python script</p>

```<code>/usr/bin/wkhtmltopdf: symbol lookup error: /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5: undefined symbol: FT_Property_Set
</code>```

答: I experienced the same issue and the comment of @Ross led me on the correct way. The library libfreetype.so.6 was not accessible through the LD_LIBRARY_PATH. Fixing this resolved the issue.

Body:
I get this error when I try to run wkhtmltopdf command from my python script

/usr/bin/wkhtmltopdf: symbol lookup error: /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5: undefined symbol: FT_Property_Set


问:
How to change the fill rule of SKShapeNode when filling color
I'm using SKShapeNode to create a view element which is used in my game, it should be like the following picture, with only 2 visible curves and fill color inside.

Here is my code:

```<code>    override func sceneDidLoad() {

        let shapeNode = SKShapeNode()
        shapeNode.fillColor = .red
        shapeNode.strokeColor = .white
        shapeNode.lineWidth = 5

        let path = CGMutablePath()
        let radius:CGFloat = 250
        path.addArc(center: CGPoint(x:0, y:300), radius: radius, startAngle: CGFloat.pi*7/6, endAngle: CGFloat.pi*11/6, clockwise: false)
        path.addArc(center: CGPoint(x:0, y:-300), radius: radius, startAngle: CGFloat.pi*1/6, endAngle: CGFloat.pi*5/6, clockwise: false)

        shapeNode.path = path

        self.addChild(shapeNode)
    }
</code>```

But I got an extra straight line on right side which is not I want.

So I tried to move to another arc directly

```<code>        path.addArc(center: CGPoint(x:0, y:300), radius: radius, startAngle: CGFloat.pi*7/6, endAngle: CGFloat.pi*11/6, clockwise: false)
        path.move(to: CGPoint(x:cos(CGFloat.pi/6)*radius, y: -300+sin(CGFloat.pi/6)*radius))
        path.addArc(center: CGPoint(x:0, y:-300), radius: radius, startAngle: CGFloat.pi*1/6, endAngle: CGFloat.pi*5/6, clockwise: false)
</code>```

I got something like this, which is not I want either.

I've learned that I can change the fill rule of CAShapeLayer by using CGPathFillRule after checking Apple documents, but I have no idea how to connect SKShapeNode and CGPathFillRule.

Any idea about this?

答: I don't think the fill rule is going to fix things here. You need a way to separate the portions of the border that you want stroked.  Simplest is probably to create two shape nodes, one done as in your first case and filled, and a second done as the second case and stroked.</p>

Body:
I'm using SKShapeNode to create a view element which is used in my game, it should be like the following picture, with only 2 visible curves and fill color inside.

Here is my code:

    override func sceneDidLoad() {

        let shapeNode = SKShapeNode()
        shapeNode.fillColor = .red
        shapeNode.strokeColor = .white
        shapeNode.lineWidth = 5

        let path = CGMutablePath()
        let radius:CGFloat = 250
        path.addArc(center: CGPoint(x:0, y:300), radius: radius, startAngle: CGFloat.pi*7/6, endAngle: CGFloat.pi*11/6, clockwise: false)
        path.addArc(center: CGPoint(x:0, y:-300), radius: radius, startAngle: CGFloat.pi*1/6, endAngle: CGFloat.pi*5/6, clockwise: false)

        shapeNode.path = path

        self.addChild(shapeNode)
    }

But I got an extra straight line on right side which is not I want.

So I tried to move to another arc directly

        path.addArc(center: CGPoint(x:0, y:300), radius: radius, startAngle: CGFloat.pi*7/6, endAngle: CGFloat.pi*11/6, clockwise: false)
        path.move(to: CGPoint(x:cos(CGFloat.pi/6)*radius, y: -300+sin(CGFloat.pi/6)*radius))
        path.addArc(center: CGPoint(x:0, y:-300), radius: radius, startAngle: CGFloat.pi*1/6, endAngle: CGFloat.pi*5/6, clockwise: false)

I got something like this, which is not I want either.

I've learned that I can change the fill rule of CAShapeLayer by using CGPathFillRule after checking Apple documents, but I have no idea how to connect SKShapeNode and CGPathFillRule.

Any idea about this?


问:
Wait elements to be visible after click and print elements that I need Selenium Python
I want to wait for the element to be visible after click and print the element that I need. But it just doesn't wait unless I use time.sleep. I want to use

```<code>WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, 'tbody')))
</code>```

for efficiency.

Please help.

```<code>from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException

driver = webdriver.Chrome(executable_path=r"C:\Users\Kim woo jae\PycharmProjects\100개 키워드\chromedriver.exe")

ky = '화장대','침대', '고기'
for k in ky:
    driver.get("http://whereispost.com/seller/")
    box = driver.find_element_by_xpath('//*[@id="keyword"]')
    box.clear()
    box.send_keys(k)
    box.submit()
    wait = WebDriverWait(driver, 20)
    b = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, 'tbody')))
    print(b.text)
</code>```

This is the code that I want to use. But it doesn't wait for the element to be visible.

```<code>driver = webdriver.Chrome(executable_path=r"C:\Users\Kim woo jae\PycharmProjects\100개 키워드\chromedriver.exe")

ky = '화장대','침대', '고기'

for k in ky:
    driver.get("http://whereispost.com/seller/")

    box = driver.find_element_by_xpath('//*[@id="keyword"]')
    box.clear()
    box.send_keys(k)
    box.submit()
  **time.sleep(3)**
    wait = WebDriverWait(driver, 20)
    b = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, 'tbody')))
    print(b.text)
</code>```

If I add time.sleep(3), it works fine. But I don't want to wait for 3 seconds if elements are already visible.

答:
tbody is always there; it is empty until you do a search.

Try waiting for some results in tbody, such as:

```<code>wait = WebDriverWait(driver, 20)
b = wait.until(EC.visibility_of_element_located((By.XPATH, '//tbody//tr')))
</code>```

Body:
I want to wait for the element to be visible after click and print the element that I need. But it just doesn't wait unless I use time.sleep. I want to use

WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, 'tbody')))

for efficiency.

Please help.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException

driver = webdriver.Chrome(executable_path=r"C:\Users\Kim woo jae\PycharmProjects\100개 키워드\chromedriver.exe")

ky = '화장대','침대', '고기'
for k in ky:
    driver.get("http://whereispost.com/seller/")
    box = driver.find_element_by_xpath('//*[@id="keyword"]')
    box.clear()
    box.send_keys(k)
    box.submit()
    wait = WebDriverWait(driver, 20)
    b = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, 'tbody')))
    print(b.text)

This is the code that I want to use. But it doesn't wait for the element to be visible.

driver = webdriver.Chrome(executable_path=r"C:\Users\Kim woo jae\PycharmProjects\100개 키워드\chromedriver.exe")

ky = '화장대','침대', '고기'

for k in ky:
    driver.get("http://whereispost.com/seller/")

    box = driver.find_element_by_xpath('//*[@id="keyword"]')
    box.clear()
    box.send_keys(k)
    box.submit()
  **time.sleep(3)**
    wait = WebDriverWait(driver, 20)
    b = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, 'tbody')))
    print(b.text)

If I add time.sleep(3), it works fine. But I don't want to wait for 3 seconds if elements are already visible.

Body:
tbody is always there; it is empty until you do a search.

Try waiting for some results in tbody, such as:

wait = WebDriverWait(driver, 20)
b = wait.until(EC.visibility_of_element_located((By.XPATH, '//tbody//tr')))


问:
Ambassador helm chart upgrade fails with resource already exists in the cluster and wasn't defined in the previous release error
Updating ambassador helm chart with

helm upgrade --install --wait ambassador -f ambassador-helm-values.yaml stable/ambassador

fails with:

UPGRADE FAILED
Error: kind ClusterRoleBinding with the name "ambassador-crds" already exists in the cluster and wasn't defined in the previous release. Before upgrading, please either delete the resource from the cluster or remove it from the chart
Error: UPGRADE FAILED: kind ClusterRoleBinding with the name "ambassador-crds" already exists in the cluster and wasn't defined in the previous release. Before upgrading, please either delete the resource from the cluster or remove it from the chart
```

Deleted ClusterRoleBinding ambassador-crds and tried to run helm upgrade command. Which generates the ambassador-crds again and fails with same error message.

答:
I am using helm version 2.15.*. This seems to be a bug on helm (or Tiller). The option --cleanun-on-fail does not seem to work either. I use to delete the resource that's complaining about and run the helm upgrade again but I find it annoying having to do this repeatedly. What works for me is adding the option --atomic. If provided, the upgrade process rolls back changes made in case of failed upgrade.

The seems to be an issue with Tiller(server-side db) getting corrupted. See discussion here in github: https://github.com/helm/helm/issues/6031

Body:
Updating ambassador helm chart with

helm upgrade --install --wait ambassador -f ambassador-helm-values.yaml stable/ambassador

fails with:

UPGRADE FAILED
Error: kind ClusterRoleBinding with the name "ambassador-crds" already exists in the cluster and wasn't defined in the previous release. Before upgrading, please either delete the resource from the cluster or remove it from the chart
Error: UPGRADE FAILED: kind ClusterRoleBinding with the name "ambassador-crds" already exists in the cluster and wasn't defined in the previous release. Before upgrading, please either delete the resource from the cluster or remove it from the chart

Deleted ClusterRoleBinding ambassador-crds and tried to run helm upgrade command. Which generates the ambassador-crds again and fails with same error message.


问:
MS Access - How to show dates officers participate in skill test
I have a MS Access query that shows officer ID's with test scores and the dates they took each type of annual certification test.  However, I'm trying to group by officer ID and list on a single row for each officer the dates for each type of test they took so I can flag when they are due to take the same type of test again.  The officers don't take all types of tests on the same day, and typically not on on the same day as other officers.  As an example, an officer may qualify for a daytime shoot and nighttime shoot on one day, then 4 months later qualify at a rifle shoot.  I would like to show all the dates for each officer where scores were entered regardless of the score.

The fields in my query are:

```<code>OfficerID, TestDate, DayScore, NightScore, RifleScore
</code>```

I'm trying to get it to obtain results like these:

```<code>JohnDoe123, 03/15/2010, 03/15/2010, 10/04/2010

FJacobs123, 02/01/2010, 04/27/2010, 11/11/2010
</code>```

I'm basically substituting the qualification date for the score.  It seems like it should be pretty simple, but I'm stuck.  Please help.

Thanks.

答:
Perhaps not exactly what you want, but look into CrossTab queries.  That can pull in all values in a single column and display them as their own fields in line with their associated record.  What you'd end up with is a matrix of names and dates, and your query could put a "Y" in that date field if a test was taken on that date.  This would also vertically align officers that took tests on the same days.

```<code>Officer Name | 02/01/2010 | 03/15/2010 | 03/15/2010 | 04/27/2010 | 10/04/2010 | 11/11/2010
JohnDoe123   |            |     Y      |     Y      |            |     Y      |
FJacobs123   |     Y      |            |            |     Y      |            |     Y
</code>```

Body:
I have a MS Access query that shows officer ID's with test scores and the dates they took each type of annual certification test.  However, I'm trying to group by officer ID and list on a single row for each officer the dates for each type of test they took so I can flag when they are due to take the same type of test again.  The officers don't take all types of tests on the same day, and typically not on on the same day as other officers.  As an example, an officer may qualify for a daytime shoot and nighttime shoot on one day, then 4 months later qualify at a rifle shoot.  I would like to show all the dates for each officer where scores were entered regardless of the score.

The fields in my query are:

OfficerID, TestDate, DayScore, NightScore, RifleScore

I'm trying to get it to obtain results like these:

JohnDoe123, 03/15/2010, 03/15/2010, 10/04/2010

FJacobs123, 02/01/2010, 04/27/2010, 11/11/2010

I'm basically substituting the qualification date for the score.  It seems like it should be pretty simple, but I'm stuck.  Please help.

Thanks.

Body:
Perhaps not exactly what you want, but look into CrossTab queries.  That can pull in all values in a single column and display them as their own fields in line with their associated record.  What you'd end up with is a matrix of names and dates, and your query could put a "Y" in that date field if a test was taken on that date.  This would also vertically align officers that took tests on the same days.

Officer Name | 02/01/2010 | 03/15/2010 | 03/15/2010 | 04/27/2010 | 10/04/2010 | 11/11/2010
JohnDoe123   |            |     Y      |     Y      |            |     Y      |
FJacobs123   |     Y      |            |            |     Y      |            |     Y