<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Synchronize the opengrid data to your computer.
There are two different solutions.  
The first approach is based on the tmpo data format and uses a local database. This approach is more elegant, but does not cover historic data from before 23rd of October 2014.
The second is based on csv files that are stored on the opengrid webserver.  These csv files are extracted from the flukso webserver and stored as a zip file per day.  This script will only download missing files and convert all the data into a single csv per sensor. This approach covers all possible opengrid data as for now.
Step1:  Run the cell below if you want to obtain the very last houseprint information
Step2:  Create a tmpo session and load the houseprint
Step3:  Make sure all known sensors of the houseprint are added to the tmpo database.  Then synchronize all data up to now.
Step4:  CSV-based synchronization
<ASSISTANT_TASK:>
Python Code:
import os
import sys
import inspect
import tmpo
from opengrid.library import fluksoapi
from opengrid.library import houseprint
from opengrid import config
c = config.Config()
# for tmpo, only use user-speficied path if a correct path is provided
try:
    if os.path.exists(c.get('tmpo', 'data')):
        path_to_tmpo_data = c.get('tmpo', 'data')
except:
    path_to_tmpo_data = None
Explanation: Synchronize the opengrid data to your computer.
There are two different solutions.  
The first approach is based on the tmpo data format and uses a local database. This approach is more elegant, but does not cover historic data from before 23rd of October 2014.
The second is based on csv files that are stored on the opengrid webserver.  These csv files are extracted from the flukso webserver and stored as a zip file per day.  This script will only download missing files and convert all the data into a single csv per sensor. This approach covers all possible opengrid data as for now.
End of explanation
%run cache_anonymous_houseprint.py
Explanation: Run the cell below if you want to obtain the very last houseprint information
End of explanation
tmpos = tmpo.Session(path_to_tmpo_data)
tmpos.debug = True
hp = houseprint.load_houseprint_from_file('new_houseprint.pkl')
hp.init_tmpo(tmpos)
Explanation: Create a tmpo session and load the houseprint
End of explanation
hp.sync_tmpos()
Explanation: Make sure all known sensors of the houseprint are added to the tmpo database.  Then synchronize all data up to now.
End of explanation
# path to data is stored in opengrid.cfg.
# for syncing with csv
path_to_csv_data = c.get('data', 'folder') 
# This synchronization can take a while...
fluksoapi.synchronize(path_to_csv_data)
# see the other notebooks on how to import the data and start analysing.
Explanation: CSV-based synchronization
End of explanation
<END_TASK>