Skip to content

Commit

Permalink
feat: Script and template done
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebgh83 committed Feb 22, 2022
1 parent bd78c8e commit 4083cf7
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 15 deletions.
Binary file added Excel/ TABLEAU_FINAL .xlsx
Binary file not shown.
105 changes: 90 additions & 15 deletions Excel/Excel_custom_sheet.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,58 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 17,
"id": "potential-surfing",
"metadata": {},
"metadata": {
"execution": {
"iopub.execute_input": "2022-02-22T09:03:25.068625Z",
"iopub.status.busy": "2022-02-22T09:03:25.068395Z",
"iopub.status.idle": "2022-02-22T09:03:25.073779Z",
"shell.execute_reply": "2022-02-22T09:03:25.073235Z",
"shell.execute_reply.started": "2022-02-22T09:03:25.068601Z"
},
"tags": []
},
"outputs": [],
"source": [
"import naas_drivers"
"import naas_drivers\n",
"import openpyxl\n",
"from decimal import*\n",
"from openpyxl import Workbook, load_workbook\n",
"from openpyxl.styles import Color, Fill\n",
"from openpyxl.cell import Cell\n",
"from openpyxl.styles import Color, PatternFill, Font, Border\n",
"from openpyxl.styles.borders import Border, Side\n",
"from openpyxl import formatting, styles"
]
},
{
"cell_type": "markdown",
"id": "aggressive-trustee",
"metadata": {},
"source": [
"### Variables"
"### Lecture fichier Excel"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 18,
"id": "continuous-melbourne",
"metadata": {},
"metadata": {
"execution": {
"iopub.execute_input": "2022-02-22T09:03:26.268796Z",
"iopub.status.busy": "2022-02-22T09:03:26.268548Z",
"iopub.status.idle": "2022-02-22T09:03:26.340106Z",
"shell.execute_reply": "2022-02-22T09:03:26.339194Z",
"shell.execute_reply.started": "2022-02-22T09:03:26.268764Z"
},
"tags": []
},
"outputs": [],
"source": [
"stock_name = 'NFLX' "
"# Lecture du fichier Excel avec la fonction \"load_workbook\"\n",
"wb=load_workbook('TEMPLATE_BRUTE.xlsx')\n",
"ws = wb.active"
]
},
{
Expand All @@ -105,20 +133,57 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 19,
"id": "crude-louisville",
"metadata": {
"execution": {
"iopub.status.busy": "2021-02-23T14:28:14.665219Z",
"iopub.status.idle": "2021-02-23T14:28:14.668943Z",
"shell.execute_reply": "2021-02-23T14:28:14.666989Z"
"iopub.execute_input": "2022-02-22T09:03:28.269111Z",
"iopub.status.busy": "2022-02-22T09:03:28.268844Z",
"iopub.status.idle": "2022-02-22T09:03:28.301514Z",
"shell.execute_reply": "2022-02-22T09:03:28.300944Z",
"shell.execute_reply.started": "2022-02-22T09:03:28.269086Z"
},
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"table = naas_drivers.yahoofinance.get(stock_name, date_from=-3600, date_to=\"today\", moving_averages=[20,50])"
"#Définition des fonctons à appliquer à notre tableau Excel\n",
"Police = Font(name='Arial', bold = False, color = '000000', size = '11')\n",
"Fond_noir = PatternFill(start_color='000000',\n",
" end_color='000000',\n",
" fill_type= 'solid' )\n",
"Fond_vert = PatternFill(start_color='00CCFFCC',\n",
" end_color='00CCFFCC',\n",
" fill_type= 'solid' )\n",
"Entête = Font(name='Arial', bold = True, color = '00FFFFFF', size = '11', )\n",
"Bordure = Border(left=Side(border_style='thin', color='000000'), right=Side(border_style='thin',color='000000'),\n",
" top=Side(border_style='thin', color='000000'),bottom=Side(border_style='thin',color='000000'))\n",
"\n",
"# Application des fonctions \"police + bordure\"\n",
"cell_range = ws[\"A1:M54\"]\n",
"for row in cell_range:\n",
" for cell in row:\n",
" cell.font = Police\n",
" cell.border = Bordure\n",
"\n",
"# Application du séparateur de millier \n",
"cell_range = ws[\"B2:M54\"]\n",
"for row in cell_range:\n",
" for cell in row:\n",
" cell.number_format = '#,##0' \n",
" \n",
"# Mise en forme du background en noir du Header\n",
"for cell in ws[\"1:1\"]: \n",
" cell.fill = Fond_noir\n",
" \n",
"# Mise en forme du background en vert \n",
"for cell in ws[\"54:54\"]: \n",
" cell.fill = Fond_vert\n",
" \n",
"# Mise en forme de la police du Header\n",
"for cell in ws[\"1:1\"]: \n",
" cell.font = Entête"
]
},
{
Expand Down Expand Up @@ -147,12 +212,22 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 20,
"id": "offensive-poetry",
"metadata": {},
"metadata": {
"execution": {
"iopub.execute_input": "2022-02-22T09:03:33.324690Z",
"iopub.status.busy": "2022-02-22T09:03:33.324459Z",
"iopub.status.idle": "2022-02-22T09:03:33.361338Z",
"shell.execute_reply": "2022-02-22T09:03:33.360356Z",
"shell.execute_reply.started": "2022-02-22T09:03:33.324666Z"
},
"tags": []
},
"outputs": [],
"source": [
"table"
"# Enregistrement définitf du tableau final\n",
"wb.save(\" TABLEAU_FINAL \" + \".xlsx\")"
]
}
],
Expand Down
Binary file added Excel/TEMPLATE_BRUTE.xlsx
Binary file not shown.

0 comments on commit 4083cf7

Please sign in to comment.