-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13c845e
commit f59223f
Showing
1,634 changed files
with
41,904 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
211 changes: 211 additions & 0 deletions
211
DX_exploration/JSON_generating/.ipynb_checkpoints/rename & process-checkpoint.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,211 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 14, | ||
"id": "f7c7aa56", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Collecting xlsxwriterNote: you may need to restart the kernel to use updated packages.\n", | ||
"\n", | ||
" Downloading XlsxWriter-3.1.9-py3-none-any.whl (154 kB)\n", | ||
" 0.0/154.8 kB ? eta -:--:--\n", | ||
" ---------- 41.0/154.8 kB 2.0 MB/s eta 0:00:01\n", | ||
" --------------------------- 112.6/154.8 kB 2.2 MB/s eta 0:00:01\n", | ||
" -------------------------------------- 154.8/154.8 kB 1.6 MB/s eta 0:00:00\n", | ||
"Installing collected packages: xlsxwriter\n", | ||
"Successfully installed xlsxwriter-3.1.9\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# pip install xlsxwriter\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "75a633a8", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import pandas as pd\n", | ||
"import os\n", | ||
"import xlsxwriter" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 19, | ||
"id": "941a58b6", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"DataFrame for sheet 'Table 1' saved to: ./data/processed/DX_Equipment_Data_Collection_D.xlsx (Sheet: Table 1)\n", | ||
"DataFrame for sheet 'Table 2' saved to: ./data/processed/DX_Equipment_Data_Collection_D.xlsx (Sheet: Table 2)\n", | ||
"DataFrame for sheet 'Table 3' saved to: ./data/processed/DX_Equipment_Data_Collection_D.xlsx (Sheet: Table 3)\n", | ||
"DataFrame for sheet 'Table 4' saved to: ./data/processed/DX_Equipment_Data_Collection_D.xlsx (Sheet: Table 4)\n", | ||
"DataFrame for sheet 'Table 5' saved to: ./data/processed/DX_Equipment_Data_Collection_D.xlsx (Sheet: Table 5)\n", | ||
"DataFrame for sheet 'Table 6' saved to: ./data/processed/DX_Equipment_Data_Collection_D.xlsx (Sheet: Table 6)\n", | ||
"DataFrame for sheet 'Table 7' saved to: ./data/processed/DX_Equipment_Data_Collection_D.xlsx (Sheet: Table 7)\n", | ||
"DataFrame for sheet 'Table 8' saved to: ./data/processed/DX_Equipment_Data_Collection_D.xlsx (Sheet: Table 8)\n", | ||
"All sheets saved to a single Excel file: ./data/processed/DX_Equipment_Data_Collection_D.xlsx\n", | ||
"--------------------\n", | ||
"DataFrame for sheet 'Table 1' saved to: ./data/processed/DX_Equipment_Data_Collection_L.xlsx (Sheet: Table 1)\n", | ||
"DataFrame for sheet 'Table 2' saved to: ./data/processed/DX_Equipment_Data_Collection_L.xlsx (Sheet: Table 2)\n", | ||
"DataFrame for sheet 'Table 3' saved to: ./data/processed/DX_Equipment_Data_Collection_L.xlsx (Sheet: Table 3)\n", | ||
"DataFrame for sheet 'Table 4' saved to: ./data/processed/DX_Equipment_Data_Collection_L.xlsx (Sheet: Table 4)\n", | ||
"DataFrame for sheet 'Table 5' saved to: ./data/processed/DX_Equipment_Data_Collection_L.xlsx (Sheet: Table 5)\n", | ||
"DataFrame for sheet 'Table 6' saved to: ./data/processed/DX_Equipment_Data_Collection_L.xlsx (Sheet: Table 6)\n", | ||
"DataFrame for sheet 'Table 7' saved to: ./data/processed/DX_Equipment_Data_Collection_L.xlsx (Sheet: Table 7)\n", | ||
"DataFrame for sheet 'Table 8' saved to: ./data/processed/DX_Equipment_Data_Collection_L.xlsx (Sheet: Table 8)\n", | ||
"DataFrame for sheet 'Table 9' saved to: ./data/processed/DX_Equipment_Data_Collection_L.xlsx (Sheet: Table 9)\n", | ||
"DataFrame for sheet 'Table 10' saved to: ./data/processed/DX_Equipment_Data_Collection_L.xlsx (Sheet: Table 10)\n", | ||
"All sheets saved to a single Excel file: ./data/processed/DX_Equipment_Data_Collection_L.xlsx\n", | ||
"--------------------\n", | ||
"DataFrame for sheet 'Table 1' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SM.xlsx (Sheet: Table 1)\n", | ||
"DataFrame for sheet 'Table 2' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SM.xlsx (Sheet: Table 2)\n", | ||
"DataFrame for sheet 'Table 3' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SM.xlsx (Sheet: Table 3)\n", | ||
"DataFrame for sheet 'Table 4' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SM.xlsx (Sheet: Table 4)\n", | ||
"DataFrame for sheet 'Table 5' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SM.xlsx (Sheet: Table 5)\n", | ||
"DataFrame for sheet 'Table 6' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SM.xlsx (Sheet: Table 6)\n", | ||
"DataFrame for sheet 'Table 7' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SM.xlsx (Sheet: Table 7)\n", | ||
"DataFrame for sheet 'Table 8' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SM.xlsx (Sheet: Table 8)\n", | ||
"DataFrame for sheet 'Table 9' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SM.xlsx (Sheet: Table 9)\n", | ||
"DataFrame for sheet 'Table 10' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SM.xlsx (Sheet: Table 10)\n", | ||
"DataFrame for sheet 'Table 11' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SM.xlsx (Sheet: Table 11)\n", | ||
"DataFrame for sheet 'Table 12' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SM.xlsx (Sheet: Table 12)\n", | ||
"DataFrame for sheet 'Table 13' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SM.xlsx (Sheet: Table 13)\n", | ||
"DataFrame for sheet 'Table 14' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SM.xlsx (Sheet: Table 14)\n", | ||
"DataFrame for sheet 'Table 15' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SM.xlsx (Sheet: Table 15)\n", | ||
"DataFrame for sheet 'Table 16' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SM.xlsx (Sheet: Table 16)\n", | ||
"DataFrame for sheet 'Table 17' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SM.xlsx (Sheet: Table 17)\n", | ||
"DataFrame for sheet 'Table 18' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SM.xlsx (Sheet: Table 18)\n", | ||
"All sheets saved to a single Excel file: ./data/processed/DX_Equipment_Data_Collection_C_SM.xlsx\n", | ||
"--------------------\n", | ||
"DataFrame for sheet 'Table 1' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SubCool.xlsx (Sheet: Table 1)\n", | ||
"DataFrame for sheet 'Table 2' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SubCool.xlsx (Sheet: Table 2)\n", | ||
"DataFrame for sheet 'Table 3' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SubCool.xlsx (Sheet: Table 3)\n", | ||
"DataFrame for sheet 'Table 4' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SubCool.xlsx (Sheet: Table 4)\n", | ||
"DataFrame for sheet 'Table 5' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SubCool.xlsx (Sheet: Table 5)\n", | ||
"DataFrame for sheet 'Table 6' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SubCool.xlsx (Sheet: Table 6)\n", | ||
"DataFrame for sheet 'Table 7' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SubCool.xlsx (Sheet: Table 7)\n", | ||
"DataFrame for sheet 'Table 8' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SubCool.xlsx (Sheet: Table 8)\n", | ||
"DataFrame for sheet 'Table 9' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SubCool.xlsx (Sheet: Table 9)\n", | ||
"DataFrame for sheet 'Table 10' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SubCool.xlsx (Sheet: Table 10)\n", | ||
"DataFrame for sheet 'Table 11' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SubCool.xlsx (Sheet: Table 11)\n", | ||
"DataFrame for sheet 'Table 12' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SubCool.xlsx (Sheet: Table 12)\n", | ||
"DataFrame for sheet 'Table 13' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SubCool.xlsx (Sheet: Table 13)\n", | ||
"DataFrame for sheet 'Table 14' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SubCool.xlsx (Sheet: Table 14)\n", | ||
"DataFrame for sheet 'Table 15' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SubCool.xlsx (Sheet: Table 15)\n", | ||
"DataFrame for sheet 'Table 16' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SubCool.xlsx (Sheet: Table 16)\n", | ||
"DataFrame for sheet 'Table 17' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SubCool.xlsx (Sheet: Table 17)\n", | ||
"DataFrame for sheet 'Table 18' saved to: ./data/processed/DX_Equipment_Data_Collection_C_SubCool.xlsx (Sheet: Table 18)\n", | ||
"All sheets saved to a single Excel file: ./data/processed/DX_Equipment_Data_Collection_C_SubCool.xlsx\n", | ||
"--------------------\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"def process_excel_file(input_path, output_folder, new_column_names):\n", | ||
" dfs = pd.read_excel(input_path, sheet_name=None, header=6, usecols=\"B:L\", engine=\"openpyxl\")\n", | ||
" os.makedirs(output_folder, exist_ok=True)\n", | ||
"\n", | ||
" # Create a writer to save all sheets in a single Excel file\n", | ||
" output_file_path = os.path.join(output_folder, f\"{os.path.basename(input_path)}\")\n", | ||
" with pd.ExcelWriter(output_file_path, engine='xlsxwriter') as writer:\n", | ||
" for sheet_name, df in dfs.items():\n", | ||
" if len(new_column_names) == len(df.columns):\n", | ||
" df.columns = new_column_names\n", | ||
" df.to_excel(writer, sheet_name=sheet_name, index=False)\n", | ||
" print(f\"DataFrame for sheet '{sheet_name}' saved to: {output_file_path} (Sheet: {sheet_name})\")\n", | ||
" else:\n", | ||
" print(f\"Number of new column names does not match the number of columns in sheet '{sheet_name}'. Skipping.\")\n", | ||
"\n", | ||
" print(f\"All sheets saved to a single Excel file: {output_file_path}\")\n", | ||
"\n", | ||
"\n", | ||
"input_excel_path_list = [\"./data/original/DX_Equipment_Data_Collection_D.xlsx\",\n", | ||
" \"./data/original/DX_Equipment_Data_Collection_L.xlsx\",\n", | ||
" \"./data/original/DX_Equipment_Data_Collection_C_SM.xlsx\",\n", | ||
" \"./data/original/DX_Equipment_Data_Collection_C_SubCool.xlsx\"]\n", | ||
"output_folder_path = \"./data/processed/\"\n", | ||
"new_column_names=[\"outdoor_coil_entering_dry_bulb_temperature\", \"indoor_coil_entering_dry_bulb_temperature\",\n", | ||
" \"indoor_coil_entering_wet_bulb_temperature\", \"indoor_coil_entering_relative_humidity\",\n", | ||
" \"gross_total_capacity\", \"gross_sensible_capacity\", \"gross_power\", \"indoor_coil_air_mass_flow_rate\",\n", | ||
" \"supply_fan_power\", \"outside_fan_power\", \"compressor_sequence_number\"]\n", | ||
"\n", | ||
"for input_excel_path in input_excel_path_list:\n", | ||
" process_excel_file(input_excel_path, output_folder_path, new_column_names)\n", | ||
" print(\"--------------------\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"id": "047a93d9", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"['Table 1',\n", | ||
" 'Table 2',\n", | ||
" 'Table 3',\n", | ||
" 'Table 4',\n", | ||
" 'Table 5',\n", | ||
" 'Table 6',\n", | ||
" 'Table 7',\n", | ||
" 'Table 8']" | ||
] | ||
}, | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"# test\n", | ||
"file_path = \"./data/original/DX_Equipment_Data_Collection_D.xlsx\"\n", | ||
"sheet_names = pd.ExcelFile(file_path).sheet_names\n", | ||
"sheet_names" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "b78f41ee", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.