Get the data from the import/export files and convert it to our format. It works for the following products:
['ACELGA', 'AJO', 'ALCACHOFA', 'APIO', 'BERENJENA', 'CALABACÍN', 'CALABAZA', 'CEBOLLA', 'COLES', 'ENDIVIA Y ESCAROLA', 'ESPÁRRAGO', 'ESPINACA', 'GUISANTE', 'JUDÍA', 'LECHUGA', 'MAÍZ DULCE', 'PATATA', 'PEPINO', 'PIMIENTO', 'PUERRO', 'TOMATE', 'ZANAHORIA Y NABO', 'AGUACATE', 'ALBARICOQUE', 'ARÁNDANO', 'CAQUI', 'CEREZA Y GUINDA', 'CIRUELA', 'FRAMBUESA', 'FRESA', 'GROSELLA', 'HIGO', 'KIWI', 'LIMÓN', 'MANDARINA', 'MANGO, GUAYABA', 'MANZANA', 'MELOCOTÓN', 'MELÓN', 'MORA', 'NARANJA', 'NECTARINA', 'OTROS CÍTRICOS', 'PERA', 'PIÑA', 'PLÁTANO', 'POMELO', 'SANDÍA', 'UVA DE MESA']
Not doing name maping, has to be done manually
In [1]:
import matplotlib.pyplot as plt
import matplotlib
import os
import pandas as pd
import numpy as np
%matplotlib inline
matplotlib.style.use('ggplot')
import datetime
import locale
import time
locale.setlocale(locale.LC_TIME, 'es_ES.UTF-8')
import glob
In [2]:
product = 'acelga/'
pro = 'production/'
imp = 'import/'
pwd = '/Volumes/MacintoshHD/_GitHub/journey-of-food/data/producto/'
aux = '/Volumes/MacintoshHD/_GitHub/journey-of-food/data/aux/'
dwd = '/Volumes/MacintoshHD/_GitHub/journey-of-food/data/raw/'
In [3]:
os.chdir(dwd)
files = os.listdir(dwd)
files
Out[3]:
In [4]:
dataImp = pd.read_excel('FH_IPRODMESK.xlsx', sheetname='2015', encoding ='utf-8',index_col=0)
dataImp.fillna(0,inplace=True)
In [5]:
dataImp.drop('Total',axis=1,inplace=True)
In [6]:
dataImp.index
Out[6]:
In [7]:
dataImp = dataImp.loc[pd.notnull(dataImp.index)]
In [8]:
dataImp.index = [x.lower() for x in dataImp.index.values.tolist()]
In [9]:
dataImp.loc[dataImp.index=='acelga'].transpose().sort_values('acelga',ascending=False).sum()
Out[9]:
In [10]:
dataImp.tail()
Out[10]:
In [ ]:
In [15]:
product = 'acelga/'
pro = 'production/'
imp = 'import/'
exp = 'export/'
pwd = '/Volumes/MacintoshHD/_GitHub/journey-of-food/data/producto/'
aux = '/Volumes/MacintoshHD/_GitHub/journey-of-food/data/aux/'
dwd = '/Volumes/MacintoshHD/_GitHub/journey-of-food/data/raw/'
In [11]:
os.chdir(dwd)
files = os.listdir(dwd)
files
Out[11]:
In [12]:
dataExp = pd.read_excel(files[0], sheetname='2015', encoding ='utf-8',index_col=0,na_values='x')
dataExp.fillna(0,inplace=True)
In [13]:
dataExp.drop('Total',axis = 1, inplace=True)
In [14]:
dataExp = dataExp.loc[pd.notnull(dataExp.index)]
In [15]:
dataExp.index = [x.lower() for x in dataExp.index.values.tolist()]
In [16]:
len(dataImp)
Out[16]:
In [67]:
for producto in dataImp.index.values:
locale.setlocale(locale.LC_TIME, 'es_ES.UTF-8')
datosImp = dataImp.loc[dataImp.index==producto]
datosExp = dataExp.loc[dataImp.index==producto]
datos = pd.concat([datosImp, datosExp])
datos.index = ['Importado','Exportado']
datos.columns=['01-Ene-2015','01-Feb-2015','01-Mar-2015','01-Abr-2015','01-May-2015','01-Jun-2015','01-Jul-2015','01-Ago-2015','01-Sep-2015','01-Oct-2015','01-Nov-2015','01-Dic-2015']
datos = datos.transpose()
datos.index.name = 'Mes'
try:
datos.to_csv(pwd+producto+'/'+producto+'_import_export_mes.csv')
except:
datos.to_csv(pwd+producto+'_import_export_mes.csv')
In [65]:
datos.index
Out[65]:
In [ ]: