Aug-24-2021, 08:49 PM
using the excel file I have attached, you can read the data with pandas
This example shows opening xlsx file with two sheets
Using your file, You can use same method to read your data, select what you want and rewrite (see references at bottom):
Data.xlsx (Size: 7.08 KB / Downloads: 104)
References:
read pandas data from excel: https://pandas.pydata.org/docs/reference...excel.html
write padnas data to excel: https://pandas.pydata.org/docs/reference...excel.html
This example shows opening xlsx file with two sheets
Using your file, You can use same method to read your data, select what you want and rewrite (see references at bottom):
import pandas as pd from pathlib import Path import os # Set starting path os.chdir(os.path.abspath(os.path.dirname(__file__))) homepath = Path('.') excel_file = homepath / '../data/excel/Data.xlsx' exfile = pd.ExcelFile(excel_file) df1 = pd.read_excel(exfile, 'ZipcodeData') df2 = pd.read_excel(exfile, 'Geography') print(f"\n{df1}\n") print(f"\n{df2}\n")
Output: CountyName CountySeat FipsCd LocalCountyId ZipCode
0 Boone Belvidere 7 4 61008
1 Boone Belvidere 7 4 61011
2 Boone Belvidere 7 4 61011
3 Boone Belvidere 7 4 61012
4 Carroll Mount Carroll 15 8 61014
5 Boone Belvidere 7 4 61038
6 Boone Belvidere 7 4 61038
7 Boone Belvidere 7 4 61038
8 Carroll Mount Carroll 15 8 61046
9 Carroll Mount Carroll 15 8 61046
10 Carroll Mount Carroll 15 8 61051
11 Carroll Mount Carroll 15 8 61053
12 Carroll Mount Carroll 15 8 61053
13 Boone Belvidere 7 4 61065
14 Boone Belvidere 7 4 61065
15 Boone Belvidere 7 4 61065
16 Carroll Mount Carroll 15 8 61074
17 Carroll Mount Carroll 15 8 61074
Zip City State Latitude Longitude Timezone Daylight savings time flag Latitude.1 Longitude.1
0 61008 Belvidere IL 42.257229 -88.84755 -6 1 42.257229 -88.84755
1 61011 Caledonia IL 42.376423 -88.93250 -6 1 42.376423 -88.93250
2 61012 Capron IL 42.401104 -88.74726 -6 1 42.401104 -88.74726
3 61014 Chadwick IL 41.970680 -89.87508 -6 1 41.970680 -89.87508
4 61038 Garden Prairie IL 42.255617 -88.74344 -6 1 42.255617 -88.74344
5 61046 Lanark IL 42.111421 -89.82436 -6 1 42.111421 -89.82436
6 61051 Milledgeville IL 41.965904 -89.75896 -6 1 41.965904 -89.75896
7 61053 Mount Carroll IL 42.100900 -89.98255 -6 1 42.100900 -89.98255
8 61065 Poplar Grove IL 42.364394 -88.84665 -6 1 42.364394 -88.84665
9 61074 Savanna IL 42.099635 -90.12858 -6 1 42.099635 -90.12858
Data.xlsx (Size: 7.08 KB / Downloads: 104)
References:
read pandas data from excel: https://pandas.pydata.org/docs/reference...excel.html
write padnas data to excel: https://pandas.pydata.org/docs/reference...excel.html