I have some variables which I will need to insert into a database (PostGres). The variables are 4-D and each has the following attributes: time, level, latitude, longitude.
For example:
print(sulphate_aerosol[0][1][400][367])
>> 3.539193384838e-06
I have 13 variables (for now!) and I need to iterate over each one, extract the data and insert it into a Postgres database.
I could do:
for i in datalength:
for j in latlenth:
for k in longlength:
for l in levellength:
insert(myVar[i][j][k][l])
But that is probably going to be slower than some of the faster methods you Python gurus can come up with.
I also think that it would probably be a good idea to store the values in an array and do a bulk insert, like shown here, so any advice on that would also be appreciated.