Last active
November 1, 2022 16:30
-
-
Save allynt/a7db4b342a8654aa8333799c5c556095 to your computer and use it in GitHub Desktop.
update metadata property names
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import click | |
import json | |
@click.command() | |
@click.option( | |
"--file", required=True, type=click.Path(dir_okay=False, exists=True) | |
) | |
def namespace_properties(file): | |
input_fp = open(file, "r") | |
data = json.load(input_fp) | |
data_layer_name = data.get("name") | |
assert data_layer_name is not None | |
for property in data.get("properties", []): | |
data_property_name = property.get("name") | |
assert data_property_name is not None | |
property["name"] = f"{data_layer_name}|{data_property_name}" | |
input_fp.close() | |
output_fp = open(file, "w") | |
json.dump(data, output_fp, indent=2) | |
output_fp.close() | |
if __name__ == "__main__": | |
namespace_properties() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## files are at: `find /media/shareddata/projects/isolation+/Aggregated_alldata -iname *allgeo2* -print` | |
## that can be piped as `find <whatever> | xargs ./namespace_properties.sh` | |
FILES=$@ | |
for file in $FILES; do | |
python namespace_properties.py --file $file; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment