# -*- coding: utf-8 -*-
"""
@author: Noemi E. Cazzaniga - 2026
@email: noemi.cazzaniga@polimi.it
"""


## Examples in README.md


from faostat import *


cred = input('Press "t" to provide token, or any other key to provide username and password')
if cred == 't':
    mytoken = input('Please, provide your token:\n')
    set_requests_args(token=mytoken)
else:
    myuser = input('Username:\n')
    mypass = input('Password:\n')
    set_requests_args(username=myuser, password=mypass)


ld = list_datasets()
print('list_datasets =')
for el in range(0,5):
	print(ld[el])

df = list_datasets_df()
print('list_datasets_df =')
for el in range(0,5):
	print(df.iloc[el,:])
    
   
pars = list_pars('QCL')
print('list_pars =')
print(pars)
    
pars_df = list_pars_df('QCL')
print('list_pars_df =')
print(pars_df)
    

a = get_par('QCL', 'area')
print('get_par =')
for el, k in enumerate(a.keys()):
	print(k, a[k])
	if el > 4:
		break

a_df = get_par_df('QCL', 'specialgroups')
print('get_par_df =')
for el in range(0,5):
	print(a_df.iloc[el,:])
    

data = get_data('QCL',pars={'element':[2312, 2313],'item':'221'})
print('get_data =')
print(data[0])
for el in range(40,45):
	print(data[el])

data_df = get_data_df('QCL',pars={'element':[2312, 2313],'item':'221'})
print('get_data_df =')
for el in range(39,44):
	print(data_df.iloc[el,:])
    
data_paginator_df = get_data_df('QCL',pars={'area': '2', 'item': '221'}, limit=10)
print('get_data_df =')
for el in range(39,44):
	print(data_df.iloc[el,:])
