3x small python with PostgreSQL function fix
Budget: £10 – £20 GBP
Hi, there I have 3 python functions that deal with data from a PostgresSQL database.
I need one new one and two of the functions need fixes:
- three little Postgres tables (see attached files in CSV form so the developer can easily reproduce)
- One python file with the functions (also attached)
- pickle file needed for one function (will send to the developer once job accepted)
Note this is part of a bigger thing so the way the data is retrieved (connection etc) via SQLALCHEMY etc can’t be changed. Of course, if there is an easier way happy to try that and the dev is free to use so it can work on his/her end but in the end, needs to work via my code setup.
In code: data function get_base_data() retrieves the relevant data from the table
So Task 1:
The function loops over all ids in the data ‘meta’ (see main function below) takes keyword out of keywords column via special id for the respective main id then runs the special id against another function to get actual filter words adds it to a list to filter data later.
The function has a list error at the moment: AttributeError: 'list' object has no attribute 'replace'
This needs to be fixed
Also, temp_list = [] below is global and will fill up with keywords that need to be cleared after each id step & should only contain the keywords retrieved from a special id for a given id then cleared and filled again - which it may be already does in the loop.
Task 2:
the get data function gets a list of all the dates currently then get_updates() takes the youngest date and retrieves all info from the table 'screen' younger than that date.
Need a new function that instead of going over the list of dates in meta[] and taking the max() it needs to:
- for every id take the date - then get all the elements from screen that are younger/newer than the date and save it back into the table as a new column
# Task 3:
This code checks a table all id if trained=0 or 1; if 0 then take id and all from table screen for that id, replace a string in a row, and saves ti, abs, and label into a csv.
This all works but it only takes the .fetchone() only gets the first ti abs label from the table details. I need all ti, abs labels for a given id Saved in the csv.
more details in the code
That’s it.
If all goes well happy to take the developer on for more tasks.
I need one new one and two of the functions need fixes:
- three little Postgres tables (see attached files in CSV form so the developer can easily reproduce)
- One python file with the functions (also attached)
- pickle file needed for one function (will send to the developer once job accepted)
Note this is part of a bigger thing so the way the data is retrieved (connection etc) via SQLALCHEMY etc can’t be changed. Of course, if there is an easier way happy to try that and the dev is free to use so it can work on his/her end but in the end, needs to work via my code setup.
In code: data function get_base_data() retrieves the relevant data from the table
So Task 1:
The function loops over all ids in the data ‘meta’ (see main function below) takes keyword out of keywords column via special id for the respective main id then runs the special id against another function to get actual filter words adds it to a list to filter data later.
The function has a list error at the moment: AttributeError: 'list' object has no attribute 'replace'
This needs to be fixed
Also, temp_list = [] below is global and will fill up with keywords that need to be cleared after each id step & should only contain the keywords retrieved from a special id for a given id then cleared and filled again - which it may be already does in the loop.
Task 2:
the get data function gets a list of all the dates currently then get_updates() takes the youngest date and retrieves all info from the table 'screen' younger than that date.
Need a new function that instead of going over the list of dates in meta[] and taking the max() it needs to:
- for every id take the date - then get all the elements from screen that are younger/newer than the date and save it back into the table as a new column
# Task 3:
This code checks a table all id if trained=0 or 1; if 0 then take id and all from table screen for that id, replace a string in a row, and saves ti, abs, and label into a csv.
This all works but it only takes the .fetchone() only gets the first ti abs label from the table details. I need all ti, abs labels for a given id Saved in the csv.
more details in the code
That’s it.
If all goes well happy to take the developer on for more tasks.