Mercurial > repos > siwaa > redelac_stics_x
comparison redelacxlsx2csv.py @ 0:dd02fab383bf draft
"planemo upload for repository https://forgemia.inra.fr/redelac commit 841d6c6ada2dad3dd575d25aab620491fda5c611"
| author | siwaa |
|---|---|
| date | Mon, 19 Jun 2023 15:32:54 +0000 |
| parents | |
| children | b91beff0963c |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:dd02fab383bf |
|---|---|
| 1 import sys | |
| 2 import pandas as pd | |
| 3 | |
| 4 redelacXlsxInputFile = sys.argv[1] | |
| 5 redelacUSMsOutputFile = sys.argv[2] | |
| 6 redelacTecOutputFile = sys.argv[3] | |
| 7 redelacIniOutputFile = sys.argv[4] | |
| 8 redelacStationOutputFile = sys.argv[5] | |
| 9 redelacListe_plantesOutputFile = sys.argv[6] | |
| 10 | |
| 11 # loading | |
| 12 | |
| 13 USMsPdf = pd.read_excel(redelacXlsxInputFile, engine = 'openpyxl', sheet_name='USMs', keep_default_na=False, na_filter = False) | |
| 14 TecPdf = pd.read_excel(redelacXlsxInputFile, engine = 'openpyxl', sheet_name='Tec') | |
| 15 IniPdf = pd.read_excel(redelacXlsxInputFile, engine = 'openpyxl', sheet_name='Ini') | |
| 16 StationPdf = pd.read_excel(redelacXlsxInputFile, engine = 'openpyxl', sheet_name='Station') | |
| 17 Liste_plantesPdf = pd.read_excel(redelacXlsxInputFile, engine = 'openpyxl', sheet_name='Liste_plantes') | |
| 18 | |
| 19 # sanityzing | |
| 20 | |
| 21 julCol = [x for x in TecPdf.columns if x.startswith('jul')] | |
| 22 | |
| 23 TecPdf[julCol] = TecPdf[julCol].astype('Int64') | |
| 24 | |
| 25 USMsPdf['fclim1'] = USMsPdf['fclim1'].astype('string') | |
| 26 USMsPdf['fclim2'] = USMsPdf['fclim1'].astype('string') | |
| 27 USMsPdf['rcp'] = USMsPdf['rcp'].astype('string') | |
| 28 | |
| 29 USMsPdf['Début'] = pd.to_datetime(USMsPdf['Début'], dayfirst = True) | |
| 30 USMsPdf['Fin'] = pd.to_datetime(USMsPdf['Fin'], dayfirst = True) | |
| 31 | |
| 32 # saving to csv | |
| 33 | |
| 34 USMsPdf.to_csv(redelacUSMsOutputFile, sep=';', date_format='%d/%m/%Y', decimal = ',', index=False) | |
| 35 TecPdf.to_csv(redelacTecOutputFile, sep=';', date_format='%d/%m/%Y', decimal = ',', float_format='%.2f', index=False) | |
| 36 IniPdf.to_csv(redelacIniOutputFile, sep=';', date_format='%d/%m/%Y', decimal = ',', index=False) | |
| 37 StationPdf.to_csv(redelacStationOutputFile, sep=';', date_format='%d/%m/%Y', decimal = ',', index=False) | |
| 38 Liste_plantesPdf.to_csv(redelacListe_plantesOutputFile, sep=';', date_format='%d/%m/%Y', decimal = ',', index=False) |
