-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_sii.py
39 lines (33 loc) · 1.11 KB
/
run_sii.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import glob
import os
import pandas as pd
import sii
from datetime import date
update_all_years = sii.yesno(prompt = u'¿Actualizar datos históricos?',
default = 'n')
update_last_year = sii.yesno(prompt = u'¿Actualizar año presente?',
default = 'y')
# Opciones lectura de archivos csv compatibles con excel spanish
karg_csvr = dict(delimiter=';', decimal=',', index_col=0, parse_dates=True)
# Opciones escrituda de archivos csv compatibles con excel spanish
karg_csvw = dict(sep=';', decimal=',')
if update_all_years:
dfs = []
yr = date.today().year
for year in range(1990,yr):
df = sii.get_data(year)
dfs.append(df)
uf = pd.concat(dfs)
uf.to_csv('uf.csv', **karg_csvw)
print uf.info()
if update_last_year:
uf = pd.read_csv('uf.csv', **karg_csvr)
yr = date.today().year
df = sii.get_data(yr)
uf = pd.concat([uf,df])
# Drop extra copy of duplicate index of Pandas Series
uf = uf.groupby(uf.index).last()
uf.to_csv('uf.csv', **karg_csvw)
print uf.info()