问:
Add Tensorboard server to Flask endpoint
I have a Flask App and a Tensorboad server. Is there a way by which I can map the Tensorboard server to one of the endpoints of Flask so that as soon as I hit that endpoint it triggers the Tensorboard server?

Flask application

```<code>from flask import Flask, jsonify, request
app = Flask(__name__)

@app.route('/hello-world', methods=['GET', 'POST'])
def say_hello():
    return jsonify({'result': 'Hello world'})

if __name__ == "__main__":
    app.run(host=host, port=5000)
</code>```

Tensorboard server code:

```<code>from tensorboard.program import TensorBoard, setup_environment
def tensorboard_main(host, port, logdir):
    configuration = list([""])
    configuration.extend(["--host", host])
    configuration.extend(["--port", port])
    configuration.extend(["--logdir", logdir])

    tensorboard = TensorBoard()
    tensorboard.configure(configuration)
    tensorboard.main()

if __name__ == "__main__":
    host = "0.0.0.0"
    port = "7070"
    logdir = '/tmp/logdir'
    tensorboard_main(host, port, logdir)
</code>```

I tried creating an endpoint in Flask app and then added tensorboard_main(host, port, logdir) in the hope that if I hit the endpoint then the server will start but I got no luck.

答:
You can use multiprocessing here: create one process for flask and another for tensorboard, then run it on the same host.

Code:

```<code>from multiprocessing import Process
from tensorboard.program import TensorBoard
from flask import Flask, jsonify

app = Flask(__name__)

def tensorboard_main(host, port, logdir):
    configuration = list([""])
    configuration.extend(["--host", host])
    configuration.extend(["--port", port])
    configuration.extend(["--logdir", logdir])

    tensorboard = TensorBoard()
    tensorboard.configure(configuration)
    tensorboard.main()

def flask_main(app, host, port):
    return app.run(host=host, port=port)

@app.route("/hello-world", methods=["GET", "POST"])
def say_hello():
    return jsonify({"result": "Hello world"})

if __name__ == "__main__":
    host = "0.0.0.0"
    port_for_tensorboard = "7070"
    port_for_flask = "5000"
    logdir = "/tmp/logdir"
    process_for_tensorboard = Process(target=tensorboard_main, args=(host, port_for_tensorboard, logdir))
    process_for_flask = Process(target=flask_main, args=(app, host, port_for_flask))
    process_for_tensorboard.start()
    process_for_flask.start()
    process_for_tensorboard.join()
    process_for_flask.join()
</code>```

If you want that inside flask endpoint tensorboard will be show some things, then you need to look at shared data from one process to another (think it would be more complicated than this example)

Body:
I have a Flask App and a Tensorboad server. Is there a way by which I can map the Tensorboard server to one of the endpoints of Flask so that as soon as I hit that endpoint it triggers the Tensorboard server?

Flask application

from flask import Flask, jsonify, request
app = Flask(__name__)

@app.route('/hello-world', methods=['GET', 'POST'])
def say_hello():
    return jsonify({'result': 'Hello world'})

if __name__ == "__main__":
    app.run(host=host, port=5000)

Tensorboard server code:

from tensorboard.program import TensorBoard, setup_environment
def tensorboard_main(host, port, logdir):
    configuration = list([""])
    configuration.extend(["--host", host])
    configuration.extend(["--port", port])
    configuration.extend(["--logdir", logdir])

    tensorboard = TensorBoard()
    tensorboard.configure(configuration)
    tensorboard.main()

if __name__ == "__main__":
    host = "0.0.0.0"
    port = "7070"
    logdir = '/tmp/logdir'
    tensorboard_main(host, port, logdir)

I tried creating an endpoint in Flask app and then added tensorboard_main(host, port, logdir) in the hope that if I hit the endpoint then the server will start but I got no luck.

Body:
You can use multiprocessing here: create one process for flask and another for tensorboard, then run it on the same host.

Code:

from multiprocessing import Process
from tensorboard.program import TensorBoard
from flask import Flask, jsonify

app = Flask(__name__)

def tensorboard_main(host, port, logdir):
    configuration = list([""])
    configuration.extend(["--host", host])
    configuration.extend(["--port", port])
    configuration.extend(["--logdir", logdir])

    tensorboard = TensorBoard()
    tensorboard.configure(configuration)
    tensorboard.main()

def flask_main(app, host, port):
    return app.run(host=host, port=port)

@app.route("/hello-world", methods=["GET", "POST"])
def say_hello():
    return jsonify({"result": "Hello world"})

if __name__ == "__main__":
    host = "0.0.0.0"
    port_for_tensorboard = "7070"
    port_for_flask = "5000"
    logdir = "/tmp/logdir"
    process_for_tensorboard = Process(target=tensorboard_main, args=(host, port_for_tensorboard, logdir))
    process_for_flask = Process(target=flask_main, args=(app, host, port_for_flask))
    process_for_tensorboard.start()
    process_for_flask.start()
    process_for_tensorboard.join()
    process_for_flask.join()

If you want that inside flask endpoint tensorboard will be show some things, then you need to look at shared data from one process to another (think it would be more complicated than this example)


来源: stackexchange

问:
How to access nested dictionary in python. how do i access total_cases
how do i access the total_cases, death in python   </p>

```<code>{'data': {'2020-05-28': {'critical': 0,
                         'death_ratio': 0.0047984644913627635,
                         'deaths': 5,
                         'recovered': 187,
                         'recovery_ratio': 0.17946257197696738,
                         'tested': 162730,
                         'total_cases': 1042},
          '2020-05-29': {'critical': 1000,
                         'death_ratio': 0.0049504950495049506,
                         'deaths': 6,
                         'recovered': 206,
                         'recovery_ratio': 0.16996699669966997,
                         'tested': 0,
                         'total_cases': 1212}},
 'status': 200,
 'type': 'stack'}
</code>```

答:
Here's a solution.
[dictionary_name['data'][i]['total_cases'] for i in dictionary_name['data'].keys()]</p>

ContentLicense: CC BY-SA 4.0

Body:
how do i access the total_cases, death in python

{'data': {'2020-05-28': {'critical': 0,
                         'death_ratio': 0.0047984644913627635,
                         'deaths': 5,
                         'recovered': 187,
                         'recovery_ratio': 0.17946257197696738,
                         'tested': 162730,
                         'total_cases': 1042},
          '2020-05-29': {'critical': 1000,
                         'death_ratio': 0.0049504950495049506,
                         'deaths': 6,
                         'recovered': 206,
                         'recovery_ratio': 0.16996699669966997,
                         'tested': 0,
                         'total_cases': 1212}},
 'status': 200,
 'type': 'stack'}


问:
Should Postgres COPY FROM be updating BRIN index?
Imagine a table like...

create table study_value (
    id serial primary key,
    study_id int not null references study (id),
    category text not null,
    subcategory int not null,
    p_value double precision not null
);
```

<p>I knew it would have 25+ million rows and they needed to be quickly queryable by the parent study as well as optionally by category and subcategory, so I chose to add a BRIN to it.</p>

<pre class="lang-sql prettyprint-override"><code>create index study_value_idx
    on study_value using brin (study_id, category, subcategory);
</code>```

All data for a given study (1mil+ rows) was inserted in bulk (ordered by category/subcategory) from a buffer via...

    copy study_value from stdin with (format csv, header false);
```

This study data was uploaded sequentially in order of study id, so the insert orderings fully respected the BRIN column order.

The problem I'm seeing is that querying this table on conditions that the BRIN satisfies, eg. select count(*) from study_value where study_id = 3;, is performing a full scan and taking 30+ seconds. The size of the BRIN itself is 48 kb.

If I reindex index study_value_idx, however, queries now take ~100 ms and the index size is over 100 kb.

Everything I've read (in PG docs, on SO, etc.) indicates that one should only need to reindex in very specific situations (eg. data corruption or indexes failing to build).

I did not need to drop the index before loading data and re-create it afterward, because copying 1 million records into the table only took 10 seconds.

Am I doing something wrong? Is there a better way to do this?

Edit:

I forgot to mention that prior to running reindex, I ran analyze study_value and saw no change.

答:
Yep, my mistake. I needed to VACUUM ANALYZE per @a_horse_with_no_name's comment.

I re-created the table and re-imported data. On fresh load, index size is again 48 kb and query is back to ~30 seconds. I had misread the query plan, though - it does use the index, the actual rows are just wildly different from expected.

```<code>Aggregate  (cost=231550.86..231550.87 rows=1 width=8) (actual time=32233.141..32233.156 rows=1 loops=1)
->  Bitmap Heap Scan on study_value  (cost=6226.26..229546.26 rows=801840 width=0) (actual time=6555.954..27253.035 rows=781580 loops=1)
     Recheck Cond: (study_id = 920)
     Rows Removed by Index Recheck: 22027434
     Heap Blocks: lossy=213169
     ->  Bitmap Index Scan on study_value_idx  (cost=0.00..6025.80 rows=801840 width=0) (actual time=16.345..16.352 rows=2132480 loops=1)
           Index Cond: (study_id = 920)
Planning time: 0.941 ms
Execution time: 32233.266 ms
</code>```

After analyze study_value (3 sec) the idx is still 48 kb and query plan is:

```<code>Aggregate  (cost=231360.49..231360.50 rows=1 width=8) (actual time=25468.247..25468.259 rows=1 loops=1)
->  Bitmap Heap Scan on study_value  (cost=6161.41..229376.81 rows=793472 width=0) (actual time=2740.866..20419.470 rows=781580 loops=1)
     Recheck Cond: (study_id = 920)
     Rows Removed by Index Recheck: 22027434
     Heap Blocks: lossy=213169
     ->  Bitmap Index Scan on study_value_idx  (cost=0.00..5963.04 rows=793472 width=0) (actual time=17.301..17.306 rows=2132480 loops=1)
           Index Cond: (study_id = 920)
Planning time: 0.101 ms
Execution time: 25468.389 ms
</code>```

After vacuum analyze study_value (20 sec) the idx is now 112kb and query plan is..

```<code>Aggregate  (cost=231496.34..231496.35 rows=1 width=8) (actual time=10038.873..10038.884 rows=1 loops=1)
->  Bitmap Heap Scan on study_value  (cost=6228.78..229501.25 rows=798037 width=0) (actual time=12.303..5133.281 rows=781580 loops=1)
     Recheck Cond: (study_id = 920)
     Rows Removed by Index Recheck: 17962
     Heap Blocks: lossy=7473
     ->  Bitmap Index Scan on study_value_idx  (cost=0.00..6029.27 rows=798037 width=0) (actual time=1.644..1.650 rows=75520 loops=1)
           Index Cond: (study_id = 920)
Planning time: 0.511 ms
Execution time: 10038.993 ms
</code>```

Executing a more detail query (ie. including category/subcategory) is much faster, maybe ~400 ms.

Body:
Imagine a table like...

create table study_value (
    id serial primary key,
    study_id int not null references study (id),
    category text not null,
    subcategory int not null,
    p_value double precision not null
);

I knew it would have 25+ million rows and they needed to be quickly queryable by the parent study as well as optionally by category and subcategory, so I chose to add a BRIN to it.

create index study_value_idx
    on study_value using brin (study_id, category, subcategory);

All data for a given study (1mil+ rows) was inserted in bulk (ordered by category/subcategory) from a buffer via...

    copy study_value from stdin with (format csv, header false);

This study data was uploaded sequentially in order of study id, so the insert orderings fully respected the BRIN column order.

The problem I'm seeing is that querying this table on conditions that the BRIN satisfies, eg. select count(*) from study_value where study_id = 3;, is performing a full scan and taking 30+ seconds. The size of the BRIN itself is 48 kb.

If I reindex index study_value_idx, however, queries now take ~100 ms and the index size is over 100 kb.

Everything I've read (in PG docs, on SO, etc.) indicates that one should only need to reindex in very specific situations (eg. data corruption or indexes failing to build).

I did not need to drop the index before loading data and re-create it afterward, because copying 1 million records into the table only took 10 seconds.

Am I doing something wrong? Is there a better way to do this?

Edit:

I forgot to mention that prior to running reindex, I ran analyze study_value and saw no change.

Body:
Yep, my mistake. I needed to VACUUM ANALYZE per @a_horse_with_no_name's comment.

I re-created the table and re-imported data. On fresh load, index size is again 48 kb and query is back to ~30 seconds. I had misread the query plan, though - it does use the index, the actual rows are just wildly different from expected.

Aggregate  (cost=231550.86..231550.87 rows=1 width=8) (actual time=32233.141..32233.156 rows=1 loops=1)
->  Bitmap Heap Scan on study_value  (cost=6226.26..229546.26 rows=801840 width=0) (actual time=6555.954..27253.035 rows=781580 loops=1)
     Recheck Cond: (study_id = 920)
     Rows Removed by Index Recheck: 22027434
     Heap Blocks: lossy=213169
     ->  Bitmap Index Scan on study_value_idx  (cost=0.00..6025.80 rows=801840 width=0) (actual time=16.345..16.352 rows=2132480 loops=1)
           Index Cond: (study_id = 920)
Planning time: 0.941 ms
Execution time: 32233.266 ms

After analyze study_value (3 sec) the idx is still 48 kb and query plan is:

Aggregate  (cost=231360.49..231360.50 rows=1 width=8) (actual time=25468.247..25468.259 rows=1 loops=1)
->  Bitmap Heap Scan on study_value  (cost=6161.41..229376.81 rows=793472 width=0) (actual time=2740.866..20419.470 rows=781580 loops=1)
     Recheck Cond: (study_id = 920)
     Rows Removed by Index Recheck: 22027434
     Heap Blocks: lossy=213169
     ->  Bitmap Index Scan on study_value_idx  (cost=0.00..5963.04 rows=793472 width=0) (actual time=17.301..17.306 rows=2132480 loops=1)
           Index Cond: (study_id = 920)
Planning time: 0.101 ms
Execution time: 25468.389 ms

After vacuum analyze study_value (20 sec) the idx is now 112kb and query plan is..

Aggregate  (cost=231496.34..231496.35 rows=1 width=8) (actual time=10038.873..10038.884 rows=1 loops=1)
->  Bitmap Heap Scan on study_value  (cost=6228.78..229501.25 rows=798037 width=0) (actual time=12.303..5133.281 rows=781580 loops=1)
     Recheck Cond: (study_id = 920)
     Rows Removed by Index Recheck: 17962
     Heap Blocks: lossy=7473
     ->  Bitmap Index Scan on study_value_idx  (cost=0.00..6029.27 rows=798037 width=0) (actual time=1.644..1.650 rows=75520 loops=1)
           Index Cond: (study_id = 920)
Planning time: 0.511 ms
Execution time: 10038.993 ms

Executing a more detail query (ie. including category/subcategory) is much faster, maybe ~400 ms.


问:
color detection using opencv python
I am trying to run a script written using opencv in python which uses webcam to track colored objects (here the object is blue colored), which is also mentioned in opencv's documentation here

```<code>import cv2
import numpy as np

cap = cv2.VideoCapture(0)

while(1):

    # Take each frame
    _, frame = cap.read()

    # Convert BGR to HSV
    hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

    # define range of blue color in HSV
    lower_blue = np.array([110,50,50])
    upper_blue = np.array([130,255,255])

    # Threshold the HSV image to get only blue colors
    mask = cv2.inRange(hsv, lower_blue, upper_blue)

    # Bitwise-AND mask and original image
    res = cv2.bitwise_and(frame,frame, mask= mask)

    cv2.imshow('frame',frame)
    cv2.imshow('mask',mask)
    cv2.imshow('res',res)
    k = cv2.waitKey(5) & 0xFF
    if k == 27:
        break

cv2.destroyAllWindows()
</code>```

But this code produces error :

```<code>OpenCV Error: Sizes of input arguments do not match (The lower bounary is neither an      array of the same size and same type as src, nor a scalar) in inRange, file     /build/buildd/opencv-2.4.2+dfsg/modules/core/src/arithm.cpp, line 2527
Traceback (most recent call last):
File "blue.py", line 19, in <module>
mask = cv2.inRange(hsv, lower_blue, upper_blue)
cv2.error: /build/buildd/opencv-2.4.2+dfsg/modules/core/src/arithm.cpp:2527: error: (     (-209) The lower bounary is neither an array of the same size and same type as src, nor a scalar in function inRange
</code>```

I've tried solutions provided in related stackoverflow questions, but none of them helped.
What is the problem with the code ? why this error arises ?

I'm using opencv 2.4.2 & python 2.7 on ubuntu

答:
In order to detect the object based on color in OpenCV-python, I think this repo will help you check out this GitHub repo:

https://github.com/shashiben/Opencv/blob/master/Object%20Detection/object_detect_with_hsv.py

I did track the object based on HSV color using trackbar

ContentLicense: CC BY-SA 3.0

Title: color detection using opencv python

Body:
I am trying to run a script written using opencv in python which uses webcam to track colored objects (here the object is blue colored), which is also mentioned in opencv's documentation here

import cv2
import numpy as np

cap = cv2.VideoCapture(0)

while(1):

    # Take each frame
    _, frame = cap.read()

    # Convert BGR to HSV
    hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

    # define range of blue color in HSV
    lower_blue = np.array([110,50,50])
    upper_blue = np.array([130,255,255])

    # Threshold the HSV image to get only blue colors
    mask = cv2.inRange(hsv, lower_blue, upper_blue)

    # Bitwise-AND mask and original image
    res = cv2.bitwise_and(frame,frame, mask= mask)

    cv2.imshow('frame',frame)
    cv2.imshow('mask',mask)
    cv2.imshow('res',res)
    k = cv2.waitKey(5) & 0xFF
    if k == 27:
        break

cv2.destroyAllWindows()

But this code produces error :

OpenCV Error: Sizes of input arguments do not match (The lower bounary is neither an      array of the same size and same type as src, nor a scalar) in inRange, file     /build/buildd/opencv-2.4.2+dfsg/modules/core/src/arithm.cpp, line 2527
Traceback (most recent call last):
File "blue.py", line 19, in <module>
mask = cv2.inRange(hsv, lower_blue, upper_blue)
cv2.error: /build/buildd/opencv-2.4.2+dfsg/modules/core/src/arithm.cpp:2527: error: (     (-209) The lower bounary is neither an array of the same size and same type as src, nor a scalar in function inRange

I've tried solutions provided in related stackoverflow questions, but none of them helped.
What is the problem with the code ? why this error arises ?

I'm using opencv 2.4.2 & python 2.7 on ubuntu


问:
XML With SimpleXML Library - Performance on Android
I'm using the Simple XML library to process XML files in my Android application. These file can get quite big - around 1Mb, and can be nested pretty deeply, so they are fairly complex.

When the app loads one of these files, via the Simple API, it can take up to 30sec to complete. Currently I am passing a FileInputStream into the [read(Class, InputStream)][2] method of Simple's Persister class. Effectively it just reads the XML nodes and maps the data to instances of my model objects, replicating the XML tree structure in memory.

My question then is how do I improve the performance on Android? My current thought would be to read the contents of the file into a byte array, and pass a ByteArrayInputStream to the Persister's read method instead. I imagine the time to process the file would be quicker, but I'm not sure if the time saved would be counteracted by the time taken to read the whole file first. Also memory constraints might be an issue.

Is this a fools errand? Is there anything else I could do to increase the performance in this situation? If not I will just have to resort to improving the feedback to the user on the progress of loading the file.

Some caveats:

1) I can't change the XML library I'm using - the code in question is part of an "engine" which is used across desktop, mobile and web applications. The overhead to change it would be too much for the timebeing.

2) The data files are created by users so I don't have control over the size/depth of nesting in them.

答:
Well, there are many things you can do to improve this. Here they are.

1) On Android you should be using at least version 2.5.2, but ideally 2.5.3 as it uses KXML which is much faster and more memory efficient on Android.

2) Simple will dynamically build your object graph, this means that it will need to load classes that have not already been loaded, and build a schema for each class based on its annotations using reflection. So first use will always be by far the most expensive. Repeated use of the same persister instance will be many times faster. So try to avoid multiple persister instances, just use one if possible.

3) Try measure the time taken to read the file directly, without using the Simple XML library. How long does it take? If it takes forever then you know the performance hit here is due to the file system. Try use a BufferedInputStream to improve performance.

4) If you still notice any issues, raise it on the mailing list.

EDIT:
Android has some issues with annotation processing https://code.google.com/p/android/issues/detail?id=7811, Simple 2.6.6 fixes has implemented work arounds for these issues. Performance increases of 10 times can be observed.


问:
How to sort list of string in ascending way?
I have a list of strings. They are actually files.

```<code>image_files = ["1.jpg", "3.jpg", "2.jpg", "4.jpg", "6.jpg", "5.jpg", "20.jpg", "29.jpg", "11.jpg", "9.jpg"]
</code>```

I want to sort them like:

```<code>['1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg', '9.jpg', '11.jpg', '20.jpg', '29.jpg']
</code>```

I tried with sorted(image_files, key = len) but failed.

答:
Using list.sort() method to solve this</p>

```<code>image_files = ["1.jpg", "3.jpg", "2.jpg", "4.jpg", "6.jpg", "5.jpg", "20.jpg", "29.jpg", "11.jpg", "9.jpg"]
image_files.sort(key=lambda x : int(x.split('.')[0]))
print(image_files)
#['1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg', '9.jpg', '11.jpg', '20.jpg', '29.jpg']
</code>```

Body:
I have a list of strings. They are actually files.

image_files = ["1.jpg", "3.jpg", "2.jpg", "4.jpg", "6.jpg", "5.jpg", "20.jpg", "29.jpg", "11.jpg", "9.jpg"]

I want to sort them like:

['1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg', '9.jpg', '11.jpg', '20.jpg', '29.jpg']

I tried with sorted(image_files, key = len) but failed.

Body:
Using list.sort() method to solve this

image_files = ["1.jpg", "3.jpg", "2.jpg", "4.jpg", "6.jpg", "5.jpg", "20.jpg", "29.jpg", "11.jpg", "9.jpg"]
image_files.sort(key=lambda x : int(x.split('.')[0]))
print(image_files)
#['1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg', '9.jpg', '11.jpg', '20.jpg', '29.jpg']


问:
Can I launch protractor mobile test on the AWS Device Farm
Can I run my e2e test developed using Protractor on the AWS device farm?

Because I want to complete mobile testing of my project using the AWS device farm, and do not really understand can I do that or not. I found 3 types about that on the AWS forum, but it is too old from 2018.

First forum discussion

Second forum discussion

Third forum discussion

Maybe something changed?

I have protractor e2e tests written for the desktop browser and want to use those ones for the mobile browser too.

答:
I will answer this for both mobile browsers and desktop testing.

Mobile Browsers

AWS Device Farm has 2 execution modes: Standard Mode and Custom Mode.
Standard mode gives you granular reporting if you don't generate a report for your tests locally. This splits up the artifacts for each test.
Custom mode gives you as close as possible execution state and results as you would get locally. It does not give you the granular reporting which is fine for most as you already get reports locally which will be available on Device Farm as well. It is recommended for customers to use custom mode as that is the one that is most up to date and adds supports for latest frameworks unless of course they absolutely need granular reporting.

Protractor on Device Farm

It is not officially support today.
However, Device Farm supports Appium Nodejs in custom mode. You get a yaml file where you can run shell commands on the host machine where the tests will be executed. So in case of protractor you could select this test type (Appium Nodejs), install the missing dependencies needed for the tests, start your server, and run your tests.

The points to evaluate: Since Device Farm takes your tests as inputs, you will have to upload the zip file of your tests. I would highly recommend checking the instructions for nodejs tests and using the same. Alternatively, you can also download your tests on the fly using the yaml file.

Desktop Browsers

Device Farm has a selenium grid that you can connect to from your local machine and run your tests. The browsers Chrome and Firefox run on Windows platform and Safari is not supported today. If you use a selenium grid on your local machine for your tests, then you most likely should be able to run the same tests using the Selenium grid on Device Farm. Of course, pending validation.

If you need more help on any of these items feel free to reach out to aws-devicefarm-support@amazon.com and I can help you further.


问:
Drop rows in pandas based on the same key
How can I drop rows where column A is the key, and any rows for that key contain both "foo" and "moo" in column C

df_before:

```<code>"cat"   |"waverly way"|"foo"|10.0
"cat"   |"smokey st"  |"moo"|9.7
"rabbit"|"rapid ave"  |"foo"|6.6
"rabbit"|"far blvd"   |"too"|3.2
</code>```

df_after:

```<code>"rabbit"|"rapid ave"  |"foo"|6.6
"rabbit"|"far blvd"   |"too"|3.2
</code>```

答:
I called each column A, B, and C.
I called your df df_before.

Hope this helps (if it doesn't works completely :-P)

```<code>import pandas as pd
foomooList=['foo','moo']

df=df_before.copy()

dfA_unique_values= df.a.unique()
dfA_keepValues=[]

for x in dfA_unique_values:
    tempdf=df.copy()
    checkerDF=tempdf[tempdf.a==x]
    checkerDfC_unique_values = checkerDF.c.unique()

    if all(y in checkerDfC_unique_values for y in foomooList):
        pass #do nothing since both foo and moo are in the subset

    else:
        dfA_keepValues.append(x) #put A value in keep list

df_after=df_before[df_before.A.isin(dfA_keepValues)]
</code>```

Body:
How can I drop rows where column A is the key, and any rows for that key contain both "foo" and "moo" in column C

df_before:

"cat"   |"waverly way"|"foo"|10.0
"cat"   |"smokey st"  |"moo"|9.7
"rabbit"|"rapid ave"  |"foo"|6.6
"rabbit"|"far blvd"   |"too"|3.2

df_after:

"rabbit"|"rapid ave"  |"foo"|6.6
"rabbit"|"far blvd"   |"too"|3.2

Body:
I called each column A, B, and C.
I called your df df_before.

Hope this helps (if it doesn't works completely :-P)

import pandas as pd
foomooList=['foo','moo']

df=df_before.copy()

dfA_unique_values= df.a.unique()
dfA_keepValues=[]

for x in dfA_unique_values:
    tempdf=df.copy()
    checkerDF=tempdf[tempdf.a==x]
    checkerDfC_unique_values = checkerDF.c.unique()

    if all(y in checkerDfC_unique_values for y in foomooList):
        pass #do nothing since both foo and moo are in the subset

    else:
        dfA_keepValues.append(x) #put A value in keep list

df_after=df_before[df_before.A.isin(dfA_keepValues)]


问:
trying to update or insert records into an external excel worksheet using SQL query
I am trying to insert or update an external worksheet using SQL with VBA. Below the full function code.
The error happen when I try to open the recordset within the loop passing the sql select query.
Any help would be appreciated. I know that the connection string works as I am using it on other code.

The SQL string looks like this:

```<code>select top 1 VALUENAME FROM [TradingTotals$] WHERE LOWER(VALUENAME)= LOWER('Trading') AND VALUEDATE =29/05/2020 AND CLOSINGMONTH = 'May' ORDER BY VALUEDATE DESC)
</code>```

Full Function code

```<code>Public Function InsertClosingMonthTotals(ByVal CollOfTradeLogTotObj As Collection) As Boolean

   Dim IsSuccess As Boolean
   Dim Item As TradeLogTotalsObj
   Dim Sql As String
   Dim SqlSelect As String
   Dim ConnDbString As String

   Dim TotalRecords As Long

   Dim Name As String
   Dim Value As Variant
   Dim Trading As Variant
   Dim LongShort As Variant
   Dim Therms As Variant
   Dim Valdate As Date
   Dim ClosingMonth As String

   ClosingMonth = Helper.FormatValue(Date, formatTypes.AsMonthlongOnly)

   Set Glob_Conn = New ADODB.Connection
   Set Glob_RecSet = New ADODB.Recordset

   ' Client-side cursor for correct return of record count
   Glob_RecSet.CursorLocation = adUseClient

   'Get Connection string according to the database server type
   ConnDbString = Helper.GetConnectionString(ServerTypes.Excel, Glob_FilePathForDataInput)

   'if the connection is closed then open it
   If (Glob_Conn.State = 0) Then
      Glob_Conn.Open (ConnDbString)
   End If

   For Each Item In CollOfTradeLogTotObj
      Name = Item.Name
      Value = Helper.FormatValue(Item.Value, AsNumber)
      LongShort = Helper.FormatValue(Item.LongShort, AsDecimalThreeDigits)
      Therms = Helper.FormatValue(Item.Therms, AsDecimalThreeDigits)
      Valdate = Helper.FormatValue(Item.dateTime, AsDateDisplay)

      SqlSelect = "select top 1 VALUENAME FROM [" & Glob_SheetNameTotalBooks & "$]" & _
      " WHERE LOWER(VALUENAME)= LOWER(" & "'" & Name & "'" & ")" & " AND VALUEDATE =" & Valdate & _
      " AND CLOSINGMONTH = " & "'" & ClosingMonth & "'" & _
      " ORDER BY VALUEDATE DESC)"

      Debug.Print ("SQL SELECT " & SqlSelect)
      Debug.Print ("*************************************************************")

      'open the record set
      If (Glob_RecSet.State <> 1) Then
     ' ******* ERROR ON LINE BELOW ON OPEN **********
      Glob_RecSet.Open SqlSelect, Glob_Conn, adOpenForwardOnly, adLockOptimistic
      End If

      TotalRecords = Glob_RecSet.RecordCount
      If (TotalRecords > 0) Then
      Sql = "UPDATE TradingTotals SET VALUENAME =" & "'" & Name & "'" & _
      ",VALUEDATE =" & Valdate & _
      ",VALUE =" & Value & _
      ",LONGSHORT =" & LongShort & _
      ",THERMS =" & Therms & _
      ",CLOSINGMONTH =" & "'" & ClosingMonth & "'" & _
      "  WHERE LOWER(VALUENAME) = LOWER(" & Name & ") AND VALUEDATE = " & Valdate & " AND CLOSINGMONTH =" & ClosingMonth
      Else
      Sql = "INSERT INTO " & Glob_SheetNameTotalBooks & " (VALUENAME,VALUEDATE,VALUE, LONGSHORT, THERMS, CLOSINGMONTH )" & _
      " VALUES (" & "'" & Name & "'" & "," & Valdate & "," & Value & "," & LongShort & "," & Therms & "," & ClosingMonth & ")"
      End If

      Debug.Print ("SQL INSERT " & Sql)
      Debug.Print ("*************************************************************")

      Glob_Conn.Execute Sql

   Next Item

 'cleanup
   Helper.CloseConnectionObjects Glob_RecSet, Glob_Conn

   InsertClosingMonthTotals = IsSuccess
End Function
</code>```

EDIT
this query works

```<code>SQL SELECT select TOP 1 VALUENAME FROM [TradingTotals$] WHERE LOWER(VALUENAME) ='Trading'
</code>```

and seems that the issue is with LOWER() ; does anyone know if LOWER() cannot be used in excel queries?

EDIT 2

it seems that is just a matter of "properly" writing the query in Excel; this one below works. In the previous one tehre also was an extra ")" at the end of teh query

```<code>SQL SELECT select top 1 VALUENAME FROM [TradingTotals$] WHERE VALUENAME= 'Trading' AND VALUEDATE ='29/05/2020' AND CLOSINGMONTH = 'May' ORDER BY VALUEDATE DESC
</code>```

I am trying now to use LOWER() again

EDIT 3
LOWER() dos not work, at least in the way I am using  it in VBA;

```<code>SQL SELECT select top 1 VALUENAME FROM [TradingTotals$] WHERE LOWER(VALUENAME)='Trading' And ValueDate =  '29/05/2020' AND CLOSINGMONTH = 'May' ORDER BY VALUEDATE DESC
</code>```

I also tried double quotes for literals

答:
So at the end there were different issues but mostly due with incorrect query syntax as I am writing SQL as when querying SQL server; not yet up to speed with excel query syntax.

Thanks to all who added useful comments, I am unaware on how to accept an answer from a comment so I am posting this as an answer but no credit to me at all; all credit to the great folks that added comments here.

I am now facing other issues with the insert.. basically even if I pass numbers as long and dates it get stored in excel as general. Even if I format the columns in the spreadsheet as date and number, it get reverted again to general?? but I am opening a new question for this issue

Body:
I am trying to insert or update an external worksheet using SQL with VBA. Below the full function code.
The error happen when I try to open the recordset within the loop passing the sql select query.
Any help would be appreciated. I know that the connection string works as I am using it on other code.

The SQL string looks like this:

select top 1 VALUENAME FROM [TradingTotals$] WHERE LOWER(VALUENAME)= LOWER('Trading') AND VALUEDATE =29/05/2020 AND CLOSINGMONTH = 'May' ORDER BY VALUEDATE DESC)

Full Function code

Public Function InsertClosingMonthTotals(ByVal CollOfTradeLogTotObj As Collection) As Boolean

   Dim IsSuccess As Boolean
   Dim Item As TradeLogTotalsObj
   Dim Sql As String
   Dim SqlSelect As String
   Dim ConnDbString As String

   Dim TotalRecords As Long

   Dim Name As String
   Dim Value As Variant
   Dim Trading As Variant
   Dim LongShort As Variant
   Dim Therms As Variant
   Dim Valdate As Date
   Dim ClosingMonth As String

   ClosingMonth = Helper.FormatValue(Date, formatTypes.AsMonthlongOnly)

   Set Glob_Conn = New ADODB.Connection
   Set Glob_RecSet = New ADODB.Recordset

   ' Client-side cursor for correct return of record count
   Glob_RecSet.CursorLocation = adUseClient

   'Get Connection string according to the database server type
   ConnDbString = Helper.GetConnectionString(ServerTypes.Excel, Glob_FilePathForDataInput)

   'if the connection is closed then open it
   If (Glob_Conn.State = 0) Then
      Glob_Conn.Open (ConnDbString)
   End If

   For Each Item In CollOfTradeLogTotObj
      Name = Item.Name
      Value = Helper.FormatValue(Item.Value, AsNumber)
      LongShort = Helper.FormatValue(Item.LongShort, AsDecimalThreeDigits)
      Therms = Helper.FormatValue(Item.Therms, AsDecimalThreeDigits)
      Valdate = Helper.FormatValue(Item.dateTime, AsDateDisplay)

      SqlSelect = "select top 1 VALUENAME FROM [" & Glob_SheetNameTotalBooks & "$]" & _
      " WHERE LOWER(VALUENAME)= LOWER(" & "'" & Name & "'" & ")" & " AND VALUEDATE =" & Valdate & _
      " AND CLOSINGMONTH = " & "'" & ClosingMonth & "'" & _
      " ORDER BY VALUEDATE DESC)"

      Debug.Print ("SQL SELECT " & SqlSelect)
      Debug.Print ("*************************************************************")

      'open the record set
      If (Glob_RecSet.State <> 1) Then
     ' ******* ERROR ON LINE BELOW ON OPEN **********
      Glob_RecSet.Open SqlSelect, Glob_Conn, adOpenForwardOnly, adLockOptimistic
      End If

      TotalRecords = Glob_RecSet.RecordCount
      If (TotalRecords > 0) Then
      Sql = "UPDATE TradingTotals SET VALUENAME =" & "'" & Name & "'" & _
      ",VALUEDATE =" & Valdate & _
      ",VALUE =" & Value & _
      ",LONGSHORT =" & LongShort & _
      ",THERMS =" & Therms & _
      ",CLOSINGMONTH =" & "'" & ClosingMonth & "'" & _
      "  WHERE LOWER(VALUENAME) = LOWER(" & Name & ") AND VALUEDATE = " & Valdate & " AND CLOSINGMONTH =" & ClosingMonth
      Else
      Sql = "INSERT INTO " & Glob_SheetNameTotalBooks & " (VALUENAME,VALUEDATE,VALUE, LONGSHORT, THERMS, CLOSINGMONTH )" & _
      " VALUES (" & "'" & Name & "'" & "," & Valdate & "," & Value & "," & LongShort & "," & Therms & "," & ClosingMonth & ")"
      End If

      Debug.Print ("SQL INSERT " & Sql)
      Debug.Print ("*************************************************************")

      Glob_Conn.Execute Sql

   Next Item

 'cleanup
   Helper.CloseConnectionObjects Glob_RecSet, Glob_Conn

   InsertClosingMonthTotals = IsSuccess
End Function

EDIT
this query works

SQL SELECT select TOP 1 VALUENAME FROM [TradingTotals$] WHERE LOWER(VALUENAME) ='Trading'

and seems that the issue is with LOWER() ; does anyone know if LOWER() cannot be used in excel queries?

EDIT 2

it seems that is just a matter of "properly" writing the query in Excel; this one below works. In the previous one tehre also was an extra ")" at the end of teh query

SQL SELECT select top 1 VALUENAME FROM [TradingTotals$] WHERE VALUENAME= 'Trading' AND VALUEDATE ='29/05/2020' AND CLOSINGMONTH = 'May' ORDER BY VALUEDATE DESC

I am trying now to use LOWER() again

EDIT 3
LOWER() dos not work, at least in the way I am using  it in VBA;

SQL SELECT select top 1 VALUENAME FROM [TradingTotals$] WHERE LOWER(VALUENAME)='Trading' And ValueDate =  '29/05/2020' AND CLOSINGMONTH = 'May' ORDER BY VALUEDATE DESC

I also tried double quotes for literals


问:
Last Item in recyclerview is cut off
I am using recyclerview to display a list of items and constraint layout is the parent view. The layout is displayed  below:

```<code>  <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:layout_height="match_parent">

        <!-- Load the toolbar here -->
        <android.support.v7.widget.Toolbar
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/toolbar"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:fitsSystemWindows="true"
            android:minHeight="?android:attr/actionBarSize"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            android:background="@color/colorPrimary"/>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:visibility="visible"
            app:layout_constraintTop_toBottomOf="@+id/toolbar" />

        <ImageView
            android:id="@+id/imageViewContent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintTop_toBottomOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintBottom_toTopOf="parent"
            android:visibility="gone"
            android:src="@drawable/empty_category"/>

        <TextView
            android:id="@+id/textViewContent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:gravity="center"
            android:text="Empty Category"
            android:textStyle="bold"
            android:textColor="@color/colorPrimary"
            android:textAppearance="@style/TextAppearance.AppCompat.Large"
            android:visibility="gone"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/imageViewContent" />

    </android.support.constraint.ConstraintLayout>

The adapter layout for each row is presented below:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <FrameLayout
        android:id="@+id/framelayoutImage"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/buttonCart"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp">

        <ImageView
            android:id="@+id/imageViewCoverArt"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:scaleType="center" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:background="#59000000"
            android:orientation="vertical">

            <TextView
                android:id="@+id/textViewPrice"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|left"
                android:layout_marginLeft="10dp"
                android:clickable="false"
                android:text="$220"
                android:textAppearance="@style/TextAppearance.AppCompat.Medium"
                android:textColor="@android:color/white"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/textViewDetails"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|left"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="8dp"
                android:ellipsize="end"
                android:maxLength="17"
                android:maxLines="1"
                android:text="Lorem ipsum dolor sit amet, consecte"
                android:textAppearance="@style/TextAppearance.AppCompat.Medium"
                android:textColor="@android:color/white" />

        </LinearLayout>

    </FrameLayout>

    <Button
        android:id="@+id/buttonCart"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="8dp"
        android:background="@drawable/buttonshape"
        android:text="Add to Cart"
        android:textAppearance="@style/TextAppearance.AppCompat.Small"
        android:textColor="@android:color/white"
        android:textStyle="bold"
     />
</LinearLayout>
</code>```

After running my application the layouts are presented in the image below:

I tried adding a bottom margin to the recycle view, but this has not resolved the issue. I used the following links as references: RecyclerView is cutting off the last item, RecyclerView cutting off last item and tried making those changes with no luck

答:
Try using RelativeLayout instead of ConstraintLayout.

It's working for me so it seems a problem with ConstraintLayout specifically.

Title: Last Item in recyclerview is cut off

Body:
I am using recyclerview to display a list of items and constraint layout is the parent view. The layout is displayed  below:

  <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:layout_height="match_parent">

        <android.support.v7.widget.Toolbar
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/toolbar"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:fitsSystemWindows="true"
            android:minHeight="?android:attr/actionBarSize"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            android:background="@color/colorPrimary"/>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:visibility="visible"
            app:layout_constraintTop_toBottomOf="@+id/toolbar" />

        <ImageView
            android:id="@+id/imageViewContent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintTop_toBottomOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintBottom_toTopOf="parent"
            android:visibility="gone"
            android:src="@drawable/empty_category"/>

        <TextView
            android:id="@+id/textViewContent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:gravity="center"
            android:text="Empty Category"
            android:textStyle="bold"
            android:textColor="@color/colorPrimary"
            android:textAppearance="@style/TextAppearance.AppCompat.Large"
            android:visibility="gone"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/imageViewContent" />

    </android.support.constraint.ConstraintLayout>

The adapter layout for each row is presented below:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <FrameLayout
        android:id="@+id/framelayoutImage"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/buttonCart"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp">

        <ImageView
            android:id="@+id/imageViewCoverArt"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:scaleType="center" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:background="#59000000"
            android:orientation="vertical">

            <TextView
                android:id="@+id/textViewPrice"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|left"
                android:layout_marginLeft="10dp"
                android:clickable="false"
                android:text="$220"
                android:textAppearance="@style/TextAppearance.AppCompat.Medium"
                android:textColor="@android:color/white"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/textViewDetails"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|left"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="8dp"
                android:ellipsize="end"
                android:maxLength="17"
                android:maxLines="1"
                android:text="Lorem ipsum dolor sit amet, consecte"
                android:textAppearance="@style/TextAppearance.AppCompat.Medium"
                android:textColor="@android:color/white" />

        </LinearLayout>

    </FrameLayout>

    <Button
        android:id="@+id/buttonCart"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="8dp"
        android:background="@drawable/buttonshape"
        android:text="Add to Cart"
        android:textAppearance="@style/TextAppearance.AppCompat.Small"
        android:textColor="@android:color/white"
        android:textStyle="bold"
     />
</LinearLayout>

After running my application the layouts are presented in the image below:

I tried adding a bottom margin to the recycle view, but this has not resolved the issue. I used the following links as references: RecyclerView is cutting off the last item, RecyclerView cutting off last item and tried making those changes with no luck


问:
What are "BIN" files on github?
I wanted to upload some .java files on github, I don't remember if I uploaded the right files. I have been told that the files I should've submitted were missing. I checked the last commit, and the files I should've submitted were marked with "BIN" and were of type "classname".class instead of "classname".java, underneath each one of them it says "Binary file not shown" instead of the code. I would like to know what happened so that I can avoid this in the future. I have never experienced this before on github. What did I upload? I don't think I had any .class files regarding this project. </p>

答:
From what you say seems like you added files to your commit that shouldn't be added.

Well, to fix this, just remove those files, commit and push the changes. Done.

To avoid this scenario in the future and not only for you but for your team, you can create a .gitignore file at the root of the repository. This file contains patterns of paths (files and folders) so git will ignore those files when showing the state of the branch. If there's no such .gitignore file then create one and add the following:

```<code>*.class
bin/
</code>```

Also, you can add more entries in this file to support omitting other files generated by IDE, for example. There are curated lists you can find like https://gist.github.com/chhh/4961200 or https://www.gitignore.io/api/eclipse

Title: What are "BIN" files on github?

Body:
From what you say seems like you added files to your commit that shouldn't be added.

Well, to fix this, just remove those files, commit and push the changes. Done.

To avoid this scenario in the future and not only for you but for your team, you can create a .gitignore file at the root of the repository. This file contains patterns of paths (files and folders) so git will ignore those files when showing the state of the branch. If there's no such .gitignore file then create one and add the following:

*.class
bin/

Also, you can add more entries in this file to support omitting other files generated by IDE, for example. There are curated lists you can find like https://gist.github.com/chhh/4961200 or https://www.gitignore.io/api/eclipse


问:
BigQuery Standard Get first not null value when grouping
I have a table like this:

```<code>CUSTOMERS_ID  DATE_SALES  DIMENSION
MARIO1        20200201    NULL
MARIO1        20200113    Spain
MARIO2        20200131    NULL
MARIO3        20200101    France
MARIO3        20191231    Spain
</code>```

and I need to order by CUSTOMERS_ID and DATE_SALES DESC fields. Then I want to group by CUSTOMERS_ID field and get first not null value of DIMENSION field.
The output table would be:

```<code>CUSTOMERS_ID  DIMENSION
MARIO1        Spain
MARIO2        NULL
MARIO3        France
</code>```

Any ideas? I have tried COALESCE functions, FIRST_VALUE, and I have not the results I had expected.

Thanks in advance!

答:
Below is for BigQuery Standard SQL    </p>

```<code>#standardSQL
SELECT AS VALUE ARRAY_AGG(t ORDER BY IF(DIMENSION IS NULL, NULL, DATE_SALES) DESC LIMIT 1)[OFFSET(0)]
FROM `project.dataset.table` t
GROUP BY CUSTOMERS_ID
</code>```

<p>if to apply to sample data from your question - result is      </p>

```<code>Row CUSTOMERS_ID    DATE_SALES  DIMENSION
1   MARIO1          20200113    Spain
2   MARIO2          20200131    null
3   MARIO3          20200101    France
</code>```

Body:
I have a table like this:

CUSTOMERS_ID  DATE_SALES  DIMENSION
MARIO1        20200201    NULL
MARIO1        20200113    Spain
MARIO2        20200131    NULL
MARIO3        20200101    France
MARIO3        20191231    Spain

and I need to order by CUSTOMERS_ID and DATE_SALES DESC fields. Then I want to group by CUSTOMERS_ID field and get first not null value of DIMENSION field.
The output table would be:

CUSTOMERS_ID  DIMENSION
MARIO1        Spain
MARIO2        NULL
MARIO3        France

Any ideas? I have tried COALESCE functions, FIRST_VALUE, and I have not the results I had expected.

Thanks in advance!

Body:
Below is for BigQuery Standard SQL

#standardSQL
SELECT AS VALUE ARRAY_AGG(t ORDER BY IF(DIMENSION IS NULL, NULL, DATE_SALES) DESC LIMIT 1)[OFFSET(0)]
FROM `project.dataset.table` t
GROUP BY CUSTOMERS_ID

if to apply to sample data from your question - result is

Row CUSTOMERS_ID    DATE_SALES  DIMENSION
1   MARIO1          20200113    Spain
2   MARIO2          20200131    null
3   MARIO3          20200101    France


问:
How to loop over an Array with JavaScript?
I have a string that has data separated by a pipe character (|).

Example

```<code>var somestring = "data1|data2|data3";
var separated = somestring.split("|");
</code>```

I know how to use the split() to separate each data.

However, I don't know how many pipes there will be in the resulting Array.

In jQuery or JavaScript, how do I loop over the array returned?

答:
If your question really is "how do I loop through each separated variable?" then:</p>

```<code>for (var i = 0; i < separated.length; i++)
{
 //Do something with separated[i];
}

//or  (apparently this is deprecated)

for(var a in separated)
{
  //Do something with a
}
</code>```

Body:
I have a string that has data separated by a pipe character (|).

Example

var somestring = "data1|data2|data3";
var separated = somestring.split("|");

I know how to use the split() to separate each data.

However, I don't know how many pipes there will be in the resulting Array.

In jQuery or JavaScript, how do I loop over the array returned?

Body:
If your question really is "how do I loop through each separated variable?" then:

for (var i = 0; i < separated.length; i++)
{
 //Do something with separated[i];
}

//or  (apparently this is deprecated)

for(var a in separated)
{
  //Do something with a
}


问:
Babel-Loader Error Plugin/Preset files are not allowed to export objects, only functions
After updating all my outdated npm packages to @latest, my electron app fails to start, giving the error

ERROR in ./src/index.js
  [0] Module build failed (from ./node_modules/babel-loader/lib/index.js):
  [0] Error: Plugin/Preset files are not allowed to export objects, only functions. In /Users/nyxynyx/foobar/node_modules/babel-preset-stage-0/lib/index.js

Any idea what went wrong? Thank you everyone!

.babelrc

```<code>{
  "presets": ["env", "stage-0", "react"],
  "plugins": [
    "babel-plugin-styled-components",
    "react-hot-loader/babel",
    ["transform-class-properties", { "loose": true }]
  ]
}
</code>```

package.json (dependencies & devDependencies)

```<code>"dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.21",
    "@fortawesome/free-solid-svg-icons": "^5.10.1",
    "@fortawesome/react-fontawesome": "^0.1.4",
    "babel-core": "^6.26.3",
    "babel-eslint": "^10.0.2",
    "babel-loader": "^8.0.6",
    "babel-plugin-styled-components": "^1.10.6",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-polyfill": "^6.26.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-react": "^6.24.1",
    "babel-preset-stage-0": "^6.24.1",
    "babel-register": "^6.26.0",
    "bootstrap": "^4.3.1",
    "css-loader": "^3.2.0",
    "electron-log": "^3.0.7",
    "electron-updater": "^4.1.2",
    "file-loader": "^4.2.0",
    "firebase": "^6.3.4",
    "fix-path": "^2.1.0",
    "json-loader": "^0.5.7",
    "lodash": "^4.17.15",
    "menubar": "^6.0.7",
    "prop-types": "^15.7.2",
    "react": "^16.8.6",
    "react-redux": "^7.1.0",
    "react-redux-firebase": "^2.3.0",
    "reactstrap": "^8.0.1",
    "redux": "^4.0.4",
    "redux-thunk": "^2.3.0",
    "style-loader": "^1.0.0",
    "styled-components": "^4.3.2",
    "typeface-open-sans": "0.0.75",
    "url-loader": "^2.1.0"
  },
"devDependencies": {
    "concurrently": "^4.1.1",
    "devtron": "^1.4.0",
    "electron": "^6.0.1",
    "electron-builder": "^21.2.0",
    "electron-debug": "^3.0.1",
    "electron-devtools-installer": "^2.2.4",
    "eslint": "^6.1.0",
    "eslint-config-airbnb": "^17.1.1",
    "eslint-import-resolver-webpack": "^0.11.1",
    "eslint-plugin-import": "^2.18.2",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-react": "^7.14.3",
    "express": "^4.17.1",
    "react-dom": "^16.8.6",
    "react-hot-loader": "^4.12.10",
    "react-router": "^5.0.1",
    "react-router-dom": "^5.0.1",
    "stylelint": "^10.1.0",
    "stylelint-config-standard": "^18.3.0",
    "uglifyjs-webpack-plugin": "^2.2.0",
    "webpack": "^4.39.1",
    "webpack-dev-middleware": "^3.7.0",
    "webpack-hot-middleware": "^2.25.0",
    "webpack-merge": "^4.2.1"
  },
</code>```

Using node v12.6.0 on Mac OS X Mojave 10.14.5

答:
That is due to outdated babel packages being used. The babel project, just like most other active Javascript projects, have moved on to using scope packages. Hence, the package names starts with @babel

Check this to fix issue

Body:
After updating all my outdated npm packages to @latest, my electron app fails to start, giving the error

ERROR in ./src/index.js
  [0] Module build failed (from ./node_modules/babel-loader/lib/index.js):
  [0] Error: Plugin/Preset files are not allowed to export objects, only functions. In /Users/nyxynyx/foobar/node_modules/babel-preset-stage-0/lib/index.js

Any idea what went wrong? Thank you everyone!

.babelrc

{
  "presets": ["env", "stage-0", "react"],
  "plugins": [
    "babel-plugin-styled-components",
    "react-hot-loader/babel",
    ["transform-class-properties", { "loose": true }]
  ]
}

package.json (dependencies & devDependencies)

"dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.21",
    "@fortawesome/free-solid-svg-icons": "^5.10.1",
    "@fortawesome/react-fontawesome": "^0.1.4",
    "babel-core": "^6.26.3",
    "babel-eslint": "^10.0.2",
    "babel-loader": "^8.0.6",
    "babel-plugin-styled-components": "^1.10.6",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-polyfill": "^6.26.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-react": "^6.24.1",
    "babel-preset-stage-0": "^6.24.1",
    "babel-register": "^6.26.0",
    "bootstrap": "^4.3.1",
    "css-loader": "^3.2.0",
    "electron-log": "^3.0.7",
    "electron-updater": "^4.1.2",
    "file-loader": "^4.2.0",
    "firebase": "^6.3.4",
    "fix-path": "^2.1.0",
    "json-loader": "^0.5.7",
    "lodash": "^4.17.15",
    "menubar": "^6.0.7",
    "prop-types": "^15.7.2",
    "react": "^16.8.6",
    "react-redux": "^7.1.0",
    "react-redux-firebase": "^2.3.0",
    "reactstrap": "^8.0.1",
    "redux": "^4.0.4",
    "redux-thunk": "^2.3.0",
    "style-loader": "^1.0.0",
    "styled-components": "^4.3.2",
    "typeface-open-sans": "0.0.75",
    "url-loader": "^2.1.0"
  },
"devDependencies": {
    "concurrently": "^4.1.1",
    "devtron": "^1.4.0",
    "electron": "^6.0.1",
    "electron-builder": "^21.2.0",
    "electron-debug": "^3.0.1",
    "electron-devtools-installer": "^2.2.4",
    "eslint": "^6.1.0",
    "eslint-config-airbnb": "^17.1.1",
    "eslint-import-resolver-webpack": "^0.11.1",
    "eslint-plugin-import": "^2.18.2",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-react": "^7.14.3",
    "express": "^4.17.1",
    "react-dom": "^16.8.6",
    "react-hot-loader": "^4.12.10",
    "react-router": "^5.0.1",
    "react-router-dom": "^5.0.1",
    "stylelint": "^10.1.0",
    "stylelint-config-standard": "^18.3.0",
    "uglifyjs-webpack-plugin": "^2.2.0",
    "webpack": "^4.39.1",
    "webpack-dev-middleware": "^3.7.0",
    "webpack-hot-middleware": "^2.25.0",
    "webpack-merge": "^4.2.1"
  },

Using node v12.6.0 on Mac OS X Mojave 10.14.5


问:
Error when reading HDF5 as a Dask Dataframe, why?
1. My problem

I get the next error when trying to read my HDF5 file using Dask and I don't know why

```<code>>>> dd.read_hdf("test.h5", key="/RECORDS/STATES")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/dask/dataframe/io/hdf.py", line 514, in read_hdf
    for path in paths
  File "/usr/local/lib/python3.7/site-packages/dask/dataframe/io/hdf.py", line 514, in <listcomp>
    for path in paths
  File "/usr/local/lib/python3.7/site-packages/dask/dataframe/io/hdf.py", line 382, in _read_single_hdf
    for k, s, d in zip(keys, stops, divisions)
  File "/usr/local/lib/python3.7/site-packages/dask/dataframe/multi.py", line 1071, in concat
    raise ValueError("No objects to concatenate")
ValueError: No objects to concatenate
</code>```

2. The HDF5 file

The file I'm tryig to read with Dask was generated by me using the C API of HDF5. If you ask, I generate the HDF5 using C, not Python (numpy, pandas), for the sake of performance because I need to parse many GB of unformatted data in ASCII. The data is stored in the file as a HDF5 Table (https://portal.hdfgroup.org/display/HDF5/Tables). The header of my files looks like this:

```<code>HDF5 "rhoPimpleExtrae10TimeSteps.00.1iter.h5" {
GROUP "/" {
   ATTRIBUTE "hdf5_metadata_apps" {
      DATATYPE  H5T_STRING {
         STRSIZE H5T_VARIABLE;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_UTF8;
         CTYPE H5T_C_S1;
      }
      DATASPACE  SCALAR
   }
   ATTRIBUTE "hdf5_metadata_date" {
      DATATYPE  H5T_STRING {
         STRSIZE H5T_VARIABLE;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_UTF8;
         CTYPE H5T_C_S1;
      }
      DATASPACE  SCALAR
   }
   ATTRIBUTE "hdf5_metadata_hwcpu" {
      DATATYPE  H5T_STRING {
         STRSIZE H5T_VARIABLE;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_UTF8;
         CTYPE H5T_C_S1;
      }
      DATASPACE  SIMPLE { ( 48 ) / ( 48 ) }
   }
   ATTRIBUTE "hdf5_metadata_hwnodes" {
      DATATYPE  H5T_STRING {
         STRSIZE H5T_VARIABLE;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_UTF8;
         CTYPE H5T_C_S1;
      }
      DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }
   }
   ATTRIBUTE "hdf5_metadata_name" {
      DATATYPE  H5T_STRING {
         STRSIZE H5T_VARIABLE;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_UTF8;
         CTYPE H5T_C_S1;
      }
      DATASPACE  SCALAR
   }
   ATTRIBUTE "hdf5_metadata_nodes" {
      DATATYPE  H5T_STD_I64LE
      DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }
   }
   ATTRIBUTE "hdf5_metadata_path" {
      DATATYPE  H5T_STRING {
         STRSIZE H5T_VARIABLE;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_UTF8;
         CTYPE H5T_C_S1;
      }
      DATASPACE  SCALAR
   }
   ATTRIBUTE "hdf5_metadata_threads" {
      DATATYPE  H5T_STRING {
         STRSIZE H5T_VARIABLE;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_UTF8;
         CTYPE H5T_C_S1;
      }
      DATASPACE  SIMPLE { ( 48 ) / ( 48 ) }
   }
   ATTRIBUTE "hdf5_metadata_time" {
      DATATYPE  H5T_STD_I64LE
      DATASPACE  SCALAR
   }
   ATTRIBUTE "hdf5_metadata_type" {
      DATATYPE  H5T_STRING {
         STRSIZE H5T_VARIABLE;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_UTF8;
         CTYPE H5T_C_S1;
      }
      DATASPACE  SCALAR
   }
   GROUP "RECORDS" {
      DATASET "COMMUNICATIONS" {
         DATATYPE  H5T_COMPOUND {
            H5T_STD_U32LE "CPU Send ID";
            H5T_STD_U32LE "Phy. Task Send ID";
            H5T_STD_U32LE "Log. Task Send ID";
            H5T_STD_U32LE "Thread Send ID";
            H5T_STD_U64LE "Log. Send Time";
            H5T_STD_U64LE "Phy. Send Time";
            H5T_STD_U32LE "CPU Receive ID";
            H5T_STD_U32LE "Phy. Task Receive ID";
            H5T_STD_U32LE "Log. Task Receive ID";
            H5T_STD_U32LE "Thread Receive ID";
            H5T_STD_U64LE "Log. Receive Time";
            H5T_STD_U64LE "Phy. Receive Time";
            H5T_STD_U64LE "Size";
            H5T_STD_U64LE "Tag";
         }
         DATASPACE  SIMPLE { ( 67574 ) / ( H5S_UNLIMITED ) }
         ATTRIBUTE "CLASS" {
            DATATYPE  H5T_STRING {
               STRSIZE 6;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_0_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 12;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_10_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 18;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_11_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 18;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_12_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 5;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_13_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 4;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_1_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 18;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_2_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 18;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_3_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 15;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_4_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 15;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_5_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 15;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_6_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 15;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_7_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 21;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_8_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 21;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_9_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 18;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "TITLE" {
            DATATYPE  H5T_STRING {
               STRSIZE 22;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "VERSION" {
            DATATYPE  H5T_STRING {
               STRSIZE 4;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
      }
      DATASET "EVENTS" {
         DATATYPE  H5T_COMPOUND {
            H5T_STD_U32LE "CPU ID";
            H5T_STD_U16LE "APP ID";
            H5T_STD_U32LE "Task ID";
            H5T_STD_U32LE "Thread ID";
            H5T_STD_U64LE "Time";
            H5T_STD_U64LE "Event Type";
            H5T_STD_U64LE "Event Value";
         }
         DATASPACE  SIMPLE { ( 3643006 ) / ( H5S_UNLIMITED ) }
         ATTRIBUTE "CLASS" {
            DATATYPE  H5T_STRING {
               STRSIZE 6;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_0_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 7;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_1_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 7;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_2_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 8;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_3_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 10;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_4_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 5;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_5_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 11;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_6_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 12;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "TITLE" {
            DATATYPE  H5T_STRING {
               STRSIZE 14;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "VERSION" {
            DATATYPE  H5T_STRING {
               STRSIZE 4;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
      }
      DATASET "STATES" {
         DATATYPE  H5T_COMPOUND {
            H5T_STD_U32LE "CPU ID";
            H5T_STD_U16LE "APP ID";
            H5T_STD_U32LE "Task ID";
            H5T_STD_U32LE "Thread ID";
            H5T_STD_U64LE "Time ini";
            H5T_STD_U64LE "Time fi";
            H5T_STD_U16LE "State";
         }
         DATASPACE  SIMPLE { ( 301496 ) / ( H5S_UNLIMITED ) }
         ATTRIBUTE "CLASS" {
            DATATYPE  H5T_STRING {
               STRSIZE 6;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_0_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 7;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_1_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 7;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_2_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 8;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_3_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 10;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_4_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 9;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_5_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 8;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_6_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 6;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "TITLE" {
            DATATYPE  H5T_STRING {
               STRSIZE 14;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "VERSION" {
            DATATYPE  H5T_STRING {
               STRSIZE 4;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
      }
   }
}
}
</code>```

Where I basically have 3 datasets under /RECORDS (STATES, EVENTS and COMMUNICATIONS). I think my HDF5 doesn't have anything weird.
I've tried to load these datasets using Pandas and Dask arrays and it works.

3. What I would like to know

What is wrong with my HDF5 file making Dask unable to read it as a dataframe?

I've tried to find in the Dask documentation what requirements HDF5 files must satisfy, but there is nothing covering this topic. If at least I knew what problem my file has, I would be able to fix it.

答: PR https://github.com/dask/dask/pull/6204 was merged recently into dask master that, with luck, solved this issue for you.</p>

Body:
1. My problem

I get the next error when trying to read my HDF5 file using Dask and I don't know why

>>> dd.read_hdf("test.h5", key="/RECORDS/STATES")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/dask/dataframe/io/hdf.py", line 514, in read_hdf
    for path in paths
  File "/usr/local/lib/python3.7/site-packages/dask/dataframe/io/hdf.py", line 514, in <listcomp>
    for path in paths
  File "/usr/local/lib/python3.7/site-packages/dask/dataframe/io/hdf.py", line 382, in _read_single_hdf
    for k, s, d in zip(keys, stops, divisions)
  File "/usr/local/lib/python3.7/site-packages/dask/dataframe/multi.py", line 1071, in concat
    raise ValueError("No objects to concatenate")
ValueError: No objects to concatenate

2. The HDF5 file

The file I'm tryig to read with Dask was generated by me using the C API of HDF5. If you ask, I generate the HDF5 using C, not Python (numpy, pandas), for the sake of performance because I need to parse many GB of unformatted data in ASCII. The data is stored in the file as a HDF5 Table (https://portal.hdfgroup.org/display/HDF5/Tables). The header of my files looks like this:

HDF5 "rhoPimpleExtrae10TimeSteps.00.1iter.h5" {
GROUP "/" {
   ATTRIBUTE "hdf5_metadata_apps" {
      DATATYPE  H5T_STRING {
         STRSIZE H5T_VARIABLE;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_UTF8;
         CTYPE H5T_C_S1;
      }
      DATASPACE  SCALAR
   }
   ATTRIBUTE "hdf5_metadata_date" {
      DATATYPE  H5T_STRING {
         STRSIZE H5T_VARIABLE;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_UTF8;
         CTYPE H5T_C_S1;
      }
      DATASPACE  SCALAR
   }
   ATTRIBUTE "hdf5_metadata_hwcpu" {
      DATATYPE  H5T_STRING {
         STRSIZE H5T_VARIABLE;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_UTF8;
         CTYPE H5T_C_S1;
      }
      DATASPACE  SIMPLE { ( 48 ) / ( 48 ) }
   }
   ATTRIBUTE "hdf5_metadata_hwnodes" {
      DATATYPE  H5T_STRING {
         STRSIZE H5T_VARIABLE;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_UTF8;
         CTYPE H5T_C_S1;
      }
      DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }
   }
   ATTRIBUTE "hdf5_metadata_name" {
      DATATYPE  H5T_STRING {
         STRSIZE H5T_VARIABLE;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_UTF8;
         CTYPE H5T_C_S1;
      }
      DATASPACE  SCALAR
   }
   ATTRIBUTE "hdf5_metadata_nodes" {
      DATATYPE  H5T_STD_I64LE
      DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }
   }
   ATTRIBUTE "hdf5_metadata_path" {
      DATATYPE  H5T_STRING {
         STRSIZE H5T_VARIABLE;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_UTF8;
         CTYPE H5T_C_S1;
      }
      DATASPACE  SCALAR
   }
   ATTRIBUTE "hdf5_metadata_threads" {
      DATATYPE  H5T_STRING {
         STRSIZE H5T_VARIABLE;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_UTF8;
         CTYPE H5T_C_S1;
      }
      DATASPACE  SIMPLE { ( 48 ) / ( 48 ) }
   }
   ATTRIBUTE "hdf5_metadata_time" {
      DATATYPE  H5T_STD_I64LE
      DATASPACE  SCALAR
   }
   ATTRIBUTE "hdf5_metadata_type" {
      DATATYPE  H5T_STRING {
         STRSIZE H5T_VARIABLE;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_UTF8;
         CTYPE H5T_C_S1;
      }
      DATASPACE  SCALAR
   }
   GROUP "RECORDS" {
      DATASET "COMMUNICATIONS" {
         DATATYPE  H5T_COMPOUND {
            H5T_STD_U32LE "CPU Send ID";
            H5T_STD_U32LE "Phy. Task Send ID";
            H5T_STD_U32LE "Log. Task Send ID";
            H5T_STD_U32LE "Thread Send ID";
            H5T_STD_U64LE "Log. Send Time";
            H5T_STD_U64LE "Phy. Send Time";
            H5T_STD_U32LE "CPU Receive ID";
            H5T_STD_U32LE "Phy. Task Receive ID";
            H5T_STD_U32LE "Log. Task Receive ID";
            H5T_STD_U32LE "Thread Receive ID";
            H5T_STD_U64LE "Log. Receive Time";
            H5T_STD_U64LE "Phy. Receive Time";
            H5T_STD_U64LE "Size";
            H5T_STD_U64LE "Tag";
         }
         DATASPACE  SIMPLE { ( 67574 ) / ( H5S_UNLIMITED ) }
         ATTRIBUTE "CLASS" {
            DATATYPE  H5T_STRING {
               STRSIZE 6;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_0_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 12;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_10_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 18;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_11_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 18;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_12_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 5;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_13_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 4;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_1_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 18;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_2_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 18;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_3_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 15;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_4_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 15;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_5_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 15;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_6_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 15;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_7_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 21;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_8_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 21;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_9_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 18;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "TITLE" {
            DATATYPE  H5T_STRING {
               STRSIZE 22;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "VERSION" {
            DATATYPE  H5T_STRING {
               STRSIZE 4;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
      }
      DATASET "EVENTS" {
         DATATYPE  H5T_COMPOUND {
            H5T_STD_U32LE "CPU ID";
            H5T_STD_U16LE "APP ID";
            H5T_STD_U32LE "Task ID";
            H5T_STD_U32LE "Thread ID";
            H5T_STD_U64LE "Time";
            H5T_STD_U64LE "Event Type";
            H5T_STD_U64LE "Event Value";
         }
         DATASPACE  SIMPLE { ( 3643006 ) / ( H5S_UNLIMITED ) }
         ATTRIBUTE "CLASS" {
            DATATYPE  H5T_STRING {
               STRSIZE 6;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_0_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 7;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_1_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 7;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_2_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 8;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_3_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 10;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_4_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 5;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_5_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 11;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_6_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 12;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "TITLE" {
            DATATYPE  H5T_STRING {
               STRSIZE 14;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "VERSION" {
            DATATYPE  H5T_STRING {
               STRSIZE 4;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
      }
      DATASET "STATES" {
         DATATYPE  H5T_COMPOUND {
            H5T_STD_U32LE "CPU ID";
            H5T_STD_U16LE "APP ID";
            H5T_STD_U32LE "Task ID";
            H5T_STD_U32LE "Thread ID";
            H5T_STD_U64LE "Time ini";
            H5T_STD_U64LE "Time fi";
            H5T_STD_U16LE "State";
         }
         DATASPACE  SIMPLE { ( 301496 ) / ( H5S_UNLIMITED ) }
         ATTRIBUTE "CLASS" {
            DATATYPE  H5T_STRING {
               STRSIZE 6;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_0_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 7;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_1_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 7;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_2_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 8;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_3_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 10;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_4_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 9;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_5_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 8;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "FIELD_6_NAME" {
            DATATYPE  H5T_STRING {
               STRSIZE 6;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "TITLE" {
            DATATYPE  H5T_STRING {
               STRSIZE 14;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
         ATTRIBUTE "VERSION" {
            DATATYPE  H5T_STRING {
               STRSIZE 4;
               STRPAD H5T_STR_NULLTERM;
               CSET H5T_CSET_ASCII;
               CTYPE H5T_C_S1;
            }
            DATASPACE  SCALAR
         }
      }
   }
}
}

Where I basically have 3 datasets under /RECORDS (STATES, EVENTS and COMMUNICATIONS). I think my HDF5 doesn't have anything weird.
I've tried to load these datasets using Pandas and Dask arrays and it works.

3. What I would like to know

What is wrong with my HDF5 file making Dask unable to read it as a dataframe?

I've tried to find in the Dask documentation what requirements HDF5 files must satisfy, but there is nothing covering this topic. If at least I knew what problem my file has, I would be able to fix it.


问:
How to catch missing JSP file Exception
I have a JSP that includes other JSPs using code like this:

```<code><jsp:include page="include.jsp" />
</code>```

I simply want to be able catch the exception and show the end user an error message if include.jsp is missing.  How can I detect or catch the missing resource condition?

答:
by using try/catch?</p>

```<code><%
    try {
%>
        <jsp:include page="<%=filename%>" ></jsp:include>
<%
    } catch(Exception e) {
%>
        the file, <%=filename%>, is missing.
<%
    }
%>
</code>```

Title: How to catch missing JSP file Exception

Body:
I have a JSP that includes other JSPs using code like this:

<jsp:include page="include.jsp" />

I simply want to be able catch the exception and show the end user an error message if include.jsp is missing.  How can I detect or catch the missing resource condition?

Body:
by using try/catch?

<%
    try {
%>
        <jsp:include page="<%=filename%>" ></jsp:include>
<%
    } catch(Exception e) {
%>
        the file, <%=filename%>, is missing.
<%
    }
%>


答:
you can do it in jquery like this</p>

```<code>$.each(separated,function(key,item){ alert('here is ' + item + ' at position ' + key) })
</code>```

Title: How to loop over an Array with JavaScript?

Body:
you can do it in jquery like this

$.each(separated,function(key,item){ alert('here is ' + item + ' at position ' + key) })


问:
Boto: Find if bucket is public or private
I don't find a way to easily know if my AWS S3 buckets are public or private.

I was expecting to do list_bucket_response = s3client.list_buckets() and directly know if the bucket is publicly accessible or not.
I've came across https://jgreenemi.com/how-to-check-if-your-s3-buckets-allow-public-read-acls/ but in my case when I list buckets I don't get an URI.

I also tried s3client.get_bucket_acl(Bucket=bucket_name) without success.

答:
Actually get_bucket_policy_status will throw an exception if you turned off public access
I found this piece of code works well</p>

```<code>    try:
        access = s3.get_public_access_block(Bucket=bucket['Name'])
        print (access)
    except botocore.exceptions.ClientError as e:
        if e.response['Error']['Code'] == 'NoSuchPublicAccessBlockConfiguration':
            print('\t no Public Access')
        else:
            print("unexpected error: %s" % (e.response))
</code>```

Body:
Actually get_bucket_policy_status will throw an exception if you turned off public access
I found this piece of code works well

    try:
        access = s3.get_public_access_block(Bucket=bucket['Name'])
        print (access)
    except botocore.exceptions.ClientError as e:
        if e.response['Error']['Code'] == 'NoSuchPublicAccessBlockConfiguration':
            print('\t no Public Access')
        else:
            print("unexpected error: %s" % (e.response))


问:
Display a form horizontally using form_for, Ruby on Rails, twitter bootstrap
Following a Ruby on Rails tutorial and the code given below is supposed to display a form horizontally.

```<code><div class="row">
  <div class="col-md-12">
    <%= form_for(@recipe, :html => {class: "form-horizontal", role: "form"}) do |f| %>
      <div class="form-group">
        <div class="control-label col-md-2">
          <%= f.label :name %>
        </div>
        <div class="col-md-8">
          <%= f.text_field :name, class: "form-control", placeholder: "Name of recipe", autofocus: true %>
        </div>
      </div>
    <% end %>
  </div>
</div>
</code>```

However, it still displays the form vertically. I have tried this answer with wrapper snippet but still doesn't work: How to create horizontal forms with twitter bootstrap and rails simple form.

I have read from this link: https://guides.rubyonrails.org/form_helpers.html, that form_for is now soft-deprecated. Is that why? And if so how can I use form_with to achieve the same result.

Comparison:
expected
vs result

答:
here the sample for your case</p>

```<code><div class="row">
  <div class="col-md-12">
    <%= form_for(@recipe, :html => {class: "form-horizontal", role: "form"}) do |f| %>
      <div class="row form-group">
        <%= f.label :name, :class => 'control-label col-md-2' %>
        <div class="col-md-8">
          <%= f.text_field :name, class: "form-control", placeholder: "Name of recipe", autofocus: true %>
        </div>
      </div>
    <% end %>
  </div>
</div>
</code>```

Body:
Following a Ruby on Rails tutorial and the code given below is supposed to display a form horizontally.

    <%= form_for(@recipe, :html => {class: "form-horizontal", role: "form"}) do |f| %>

          <%= f.label :name %>

          <%= f.text_field :name, class: "form-control", placeholder: "Name of recipe", autofocus: true %>

    <% end %>

However, it still displays the form vertically. I have tried this answer with wrapper snippet but still doesn't work: How to create horizontal forms with twitter bootstrap and rails simple form.

I have read from this link: https://guides.rubyonrails.org/form_helpers.html, that form_for is now soft-deprecated. Is that why? And if so how can I use form_with to achieve the same result.

Comparison:
expected
vs result

Body:
here the sample for your case

<div class="row">
  <div class="col-md-12">
    <%= form_for(@recipe, :html => {class: "form-horizontal", role: "form"}) do |f| %>
      <div class="row form-group">
        <%= f.label :name, :class => 'control-label col-md-2' %>
        <div class="col-md-8">
          <%= f.text_field :name, class: "form-control", placeholder: "Name of recipe", autofocus: true %>
        </div>
      </div>
    <% end %>
  </div>
</div>