Mercurial > repos > siwaa > redelac_stics_x
view redelacxlsx2csv.py @ 1:b91beff0963c draft default tip
"planemo upload for repository https://forgemia.inra.fr/redelac/redelac-toolbox/-/tree/b275711eca6a471af5cb60ae996e0bd6c11461d6/tools/REDELACxlsx2csv commit b275711eca6a471af5cb60ae996e0bd6c11461d6-dirty"
author | siwaa |
---|---|
date | Thu, 06 Jul 2023 10:16:26 +0000 |
parents | dd02fab383bf |
children |
line wrap: on
line source
import sys import pandas as pd redelacXlsxInputFile = sys.argv[1] redelacUSMsOutputFile = sys.argv[2] redelacTecOutputFile = sys.argv[3] redelacIniOutputFile = sys.argv[4] redelacStationOutputFile = sys.argv[5] redelacListe_plantesOutputFile = sys.argv[6] # loading USMsPdf = pd.read_excel(redelacXlsxInputFile, engine = 'openpyxl', sheet_name='USMs', keep_default_na=False, na_filter = False) TecPdf = pd.read_excel(redelacXlsxInputFile, engine = 'openpyxl', sheet_name='Tec') IniPdf = pd.read_excel(redelacXlsxInputFile, engine = 'openpyxl', sheet_name='Ini') StationPdf = pd.read_excel(redelacXlsxInputFile, engine = 'openpyxl', sheet_name='Station') Liste_plantesPdf = pd.read_excel(redelacXlsxInputFile, engine = 'openpyxl', sheet_name='Liste_plantes') # sanityzing julCol = [x for x in TecPdf.columns if x.startswith('jul')] TecPdf[julCol] = TecPdf[julCol].astype('Int64') USMsPdf['fclim1'] = USMsPdf['fclim1'].astype('string') USMsPdf['fclim2'] = USMsPdf['fclim1'].astype('string') USMsPdf['rcp'] = USMsPdf['rcp'].astype('string') USMsPdf['Début'] = pd.to_datetime(USMsPdf['Début'], dayfirst = True) USMsPdf['Fin'] = pd.to_datetime(USMsPdf['Fin'], dayfirst = True) USMsPdf.loc[USMsPdf['culturean'] != 1, 'culturean'] = 0 # saving to csv USMsPdf.to_csv(redelacUSMsOutputFile, sep=';', date_format='%d/%m/%Y', decimal = ',', index=False) TecPdf.to_csv(redelacTecOutputFile, sep=';', date_format='%d/%m/%Y', decimal = ',', float_format='%.2f', index=False) IniPdf.to_csv(redelacIniOutputFile, sep=';', date_format='%d/%m/%Y', decimal = ',', index=False) StationPdf.to_csv(redelacStationOutputFile, sep=';', date_format='%d/%m/%Y', decimal = ',', index=False) Liste_plantesPdf.to_csv(redelacListe_plantesOutputFile, sep=';', date_format='%d/%m/%Y', decimal = ',', index=False)