Open
Conversation
chrowe
requested changes
Jul 20, 2023
Member
chrowe
left a comment
There was a problem hiding this comment.
I looked through the code and I made a few comments but didn't try to run because the main thing I wanted to test was the update_point_data but that doesn't seem to be finished.
Comment on lines
+17
to
+19
| from dotenv import load_dotenv | ||
| load_dotenv() | ||
|
|
Member
There was a problem hiding this comment.
I think we are mostly not including this in the scripts, though it would be nice to come up with a more standard way of handling this.
Comment on lines
-80
to
+84
| DATASET_ID = 'ea208a8b-4559-434b-82ee-95e041596a3a' | ||
|
|
||
| #DATASET_ID = 'ea208a8b-4559-434b-82ee-95e041596a3a' |
Member
There was a problem hiding this comment.
Is there a reason this is commented out?
|
|
||
| # create an empty list to store ids of data | ||
| new_ids = [] | ||
| # create an empty dataframe to store data |
Member
There was a problem hiding this comment.
Or updated to say we are creating an empty json array?
| data_df = pd.json_normalize(accumulated_json, record_path =['data']) | ||
|
|
||
|
|
||
| #TODO: cols = ['event_id_cnty','event_type', 'latitude', 'longitude'] |
|
|
||
| #TODO: New update_point_data function to update exsiting point data in in Carto table by adding new records and deleting deleted ones. Run if REFRESH_ALL_POINT_DATA is FALSE and return all records from carto as data_gdf. | ||
|
|
||
| r = cartosql.getFields('event_id_cnty', CARTO_GEO, f='csv', post=True, user=CARTO_USER, key=CARTO_KEY) |
Comment on lines
+239
to
+259
| def update_point_data(data_gdf): | ||
|
|
||
| ''' | ||
| Update point data in Carto table by adding new records and deleting deleted ones | ||
| INPUT data_gdf: geopandas dataframe storing the point ACLED data (geopandas dataframe) | ||
| RETURN data_gdf: geopandas dataframe storing the point ACLED data (geopandas dataframe) | ||
| ''' | ||
|
|
||
| # get the ids of polygons from the carto table storing administrative areas | ||
| r = cartosql.getFields('event_id_cnty', CARTO_GEO, f='csv', post=True, user=CARTO_USER, key=CARTO_KEY) | ||
|
|
||
| # turn the response into a list of ids | ||
| geo_id = r.text.split('\r\n')[1:-1] | ||
|
|
||
| # create an empty list to store the ids of rows uploaded to Carto | ||
| uploaded_ids = [] | ||
|
|
||
|
|
||
|
|
||
|
|
||
| return data_gdf |
Member
There was a problem hiding this comment.
It doesn't look like this was finished maybe?
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updated ACLED script such that the data we store in Carto is kept up to date with the API (i.e. deleted and updated).