#!/usr/bin/env python3 """Rebuild the research CSV/JSON files from transcribed primary-source table values. No network requests. Inputs are the published rounded estimates as read 2026-11-27. Run from any directory with Python 3.10+; output is written next to this script. """ import csv,json from pathlib import Path from decimal import Decimal, ROUND_HALF_UP ROOT=Path(__file__).resolve().parent; OUT=ROOT if ROOT.name=='data' else ROOT/'data'; OUT.mkdir(exist_ok=True) D='2026-11-27'; VERSION='1.0.0' BASE='https://www.eia.gov/consumption/commercial/data/' URL={ 'E03-A1':BASE+'2003/index.php', 'E18-B16':BASE+'2018/bc/html/b16.php', 'E18-B1':BASE+'2018/bc/html/b1.php', 'E12-B11':BASE+'2012/bc/cfm/b11.php', 'E12-B12':BASE+'2012/bc/cfm/b12.php', 'E18-B11':BASE+'2018/bc/html/b11.php', 'E18-B12':BASE+'2018/bc/html/b12.php', 'EIA-TYPES':'https://www.eia.gov/consumption/commercial/pba/warehouse-and-storage.php', 'EIA-FAQ':'https://www.eia.gov/consumption/commercial/faq.php', 'EIA-LATEST':'https://www.eia.gov/consumption/commercial/', 'KERR':'https://doi.org/10.1038/s41467-024-50000-0', 'BLS':'https://www.bls.gov/iag/tgs/iag493.htm', 'BLS-METHOD':'https://www.bls.gov/cew/questions-and-answers.htm', 'USDA':'https://www.nass.usda.gov/Publications/Todays_Reports/reports/rfwh0126.pdf', 'BLS-CALENDAR':'https://www.bls.gov/cew/release-calendar.htm', 'USDA-ARCHIVE':'https://esmis.nal.usda.gov/publication/capacity-refrigerated-warehouses', } def rnd(x,n=1): return float(Decimal(str(x)).quantize(Decimal('1').scaleb(-n),rounding=ROUND_HALF_UP)) def pct(a,b): return rnd(100*a/b) if b else None def change(a,b): return pct(b-a,a) def meta(ids): return {'source_ids':';'.join(ids),'source_urls':';'.join(URL[k] for k in ids),'verified_on':D} TABLES={} def save(name,rows): assert rows and all(set(r)==set(rows[0]) for r in rows),name TABLES[name]=rows with (OUT/(name+'.csv')).open('w',newline='',encoding='utf-8') as f: w=csv.DictWriter(f,fieldnames=list(rows[0])); w.writeheader(); w.writerows(rows) # EIA B11 and B12, warehouse and storage column. Counts in thousands, floor space in million ft². size_labels=['1,001–5,000','5,001–10,000','10,001–25,000','25,001–50,000','50,001–100,000','100,001–200,000','200,001–500,000','Over 500,000'] size={2012:([380,180,142,49,24,13,7,1],[1127,1329,2331,1814,1632,1946,1827,1071]),2018:([437,255,194,60,33,15,8,2],[1409,1885,3049,2199,2254,2056,2588,2043])} # National denominators are independently reported totals; never replace with sums of rounded rows. totals={2012:(796,13077,5557,87093),2018:(1004,17483,5918,96423)} rows=[] for y,(counts,areas) in size.items(): n,a,_,_=totals[y]; ids=[f'E{str(y)[-2:]}-B11',f'E{str(y)[-2:]}-B12'] for i,(lab,c,s) in enumerate(zip(size_labels,counts,areas),1): rows.append(dict(row_id=f'SIZE-{y}-{i:02}',year=y,size_sqft=lab,estimated_buildings=c*1000,floorspace_sqft=s*1000000,building_share_pct=pct(c,n),floorspace_share_pct=pct(s,a),**meta(ids))) save('warehouse-size-by-year',rows) rows=[] for y,(counts,areas) in size.items(): n,a,_,_=totals[y]; ids=[f'E{str(y)[-2:]}-B11',f'E{str(y)[-2:]}-B12'] for i,(lab,sl) in enumerate([('1,001–10,000',slice(0,2)),('10,001–100,000',slice(2,5)),('Over 100,000',slice(5,8))],1): c=sum(counts[sl]); s=sum(areas[sl]); rows.append(dict(row_id=f'GROUP-{y}-{i}',year=y,size_sqft=lab,estimated_buildings=c*1000,floorspace_sqft=s*1000000,building_share_pct=pct(c,n),floorspace_share_pct=pct(s,a),**meta(ids))) save('warehouse-size-groups',rows) # Region counts and area, same units as source. regions=[('Northeast',89,1761,119,2398),('Midwest',163,2530,307,4714),('South',325,5257,366,6365),('West',219,3529,212,4006)] rows=[] for i,(r,c12,a12,c18,a18) in enumerate(regions,1): rows.append(dict(row_id=f'REG-{i:02}',region=r,estimated_buildings_2012=c12*1000,estimated_buildings_2018=c18*1000,building_change_pct=change(c12,c18),floorspace_sqft_2012=a12*1000000,floorspace_sqft_2018=a18*1000000,floorspace_change_pct=change(a12,a18),share_of_us_buildings_2018_pct=pct(c18,1004),share_of_us_floorspace_2018_pct=pct(a18,17483),**meta(['E12-B11','E12-B12','E18-B11','E18-B12']))) save('warehouse-regions',rows) rows=[] for y,(n,a,alln,alla) in {2003:(597,10078,4859,71658),**totals}.items(): rows.append(dict(row_id=f'NAT-{y}',year=y,estimated_warehouse_storage_buildings=n*1000,warehouse_storage_floorspace_sqft=a*1000000,estimated_all_commercial_buildings=alln*1000,all_commercial_floorspace_sqft=alla*1000000,share_of_commercial_buildings_pct=pct(n,alln),share_of_commercial_floorspace_pct=pct(a,alla),**meta(['E03-A1'] if y==2003 else [f'E{str(y)[-2:]}-B11',f'E{str(y)[-2:]}-B12']))) save('warehouse-national-history',rows) # EIA Table B16: four distinct building types, plus independently published total. rows=[] for i,(label,n,a) in enumerate([('Nonrefrigerated warehouse',548,7050),('Distribution or shipping center',167,7998),('Public self-storage',285,2107),('Refrigerated warehouse',3,327),('All warehouse and storage buildings',1004,17483)],1): rows.append(dict(row_id=f'TYPE-{i:02}',year=2018,building_type=label,estimated_buildings=n*1000,floorspace_sqft=a*1000000,building_share_pct=pct(n,1004),floorspace_share_pct=pct(a,17483),**meta(['E18-B16']))) save('warehouse-building-types',rows) # BLS IAG workplace trends (source extraction 2026-11-20). rows=[] for q,p,l,s,f,status in [('2025-Q2',23190,249,7,10,'not marked preliminary'),('2025-Q3',23480,250,7,10,'not marked preliminary'),('2025-Q4',23697,250,7,10,'not marked preliminary'),('2026-Q1',23848,250,7,10,'preliminary')]: rows.append(dict(row_id='BLS-'+q,period=q,naics='493',private_establishments=p,local_government_establishments=l,state_government_establishments=s,federal_government_establishments=f,all_ownerships_sum=p+l+s+f,status=status,source_extraction_date='2026-11-20',**meta(['BLS']))) save('warehouse-industry-establishments',rows) # USDA NASS 2025 Summary p. 5 (counts), p. 7 (total gross/usable capacity). # Fields: state|public|private/semi-private|published total|gross thousand ft³|usable thousand ft³. # D = withheld, not zero. Printed dash = zero. Total counts transcribed separately. raw='''Alabama|9|9|18|42544|36806 Alaska|0|6|6|D|D Arizona|2|2|4|4103|3487 Arkansas|14|6|20|92892|81504 California|71|35|106|399675|330383 Colorado|2|1|3|D|D Connecticut|1|0|1|D|D Delaware|1|5|6|24833|18192 Florida|26|24|50|254068|203956 Georgia|31|31|62|303523|254988 Hawaii|0|0|0|0|0 Idaho|4|10|14|58075|48055 Illinois|13|14|27|190201|153279 Indiana|9|5|14|98137|77536 Iowa|15|7|22|70268|59164 Kansas|6|1|7|46067|37575 Kentucky|3|1|4|24041|22127 Louisiana|1|4|5|8400|7938 Maine|3|7|10|8154|5929 Maryland|1|2|3|D|D Massachusetts|8|4|12|54389|46240 Michigan|14|10|24|87543|70098 Minnesota|11|24|35|105422|80100 Mississippi|4|2|6|13844|11944 Missouri|5|5|10|104457|84667 Montana|0|2|2|D|D Nebraska|7|9|16|49451|39017 Nevada|2|1|3|D|D New Hampshire|0|0|0|0|0 New Jersey|19|8|27|137112|109038 New Mexico|2|3|5|D|D New York|11|17|28|55621|49855 North Carolina|12|2|14|62539|49667 North Dakota|2|1|3|10325|7800 Ohio|13|4|17|73943|63032 Oklahoma|3|5|8|9794|8581 Oregon|13|22|35|139331|113434 Pennsylvania|15|23|38|228460|196013 Rhode Island|0|0|0|0|0 South Carolina|7|5|12|76791|54688 South Dakota|3|2|5|22609|D Tennessee|6|5|11|67968|57337 Texas|26|30|56|254076|200849 Utah|7|10|17|65414|57727 Vermont|1|4|5|4818|3219 Virginia|10|3|13|72355|60324 Washington|24|28|52|300899|240004 West Virginia|0|1|1|D|D Wisconsin|39|55|94|296620|241184 Wyoming|0|0|0|0|0''' rows=[] for i,line in enumerate(raw.splitlines(),1): state,p,s,n,g,u=line.split('|'); p,s,n=map(int,(p,s,n)); assert p+s==n gg=None if g=='D' else int(g)*1000; uu=None if u=='D' else int(u)*1000 assert gg is None or uu is None or gg>=uu rows.append(dict(row_id=f'COLD-{i:02}',state=state,reference_date='2025-10-01',public_count=p,private_semiprivate_count=s,total_count=n,gross_capacity_cuft=gg,usable_capacity_cuft=uu,gross_status='withheld' if g=='D' else 'reported',usable_status='withheld' if u=='D' else 'reported',mean_gross_cuft_per_facility=round(gg/n) if gg is not None and n else None,share_of_us_facilities_pct=pct(n,931),**meta(['USDA']))) assert len(rows)==50 assert sum(r['public_count'] for r in rows)==476 assert sum(r['private_semiprivate_count'] for r in rows)==455 assert sum(r['total_count'] for r in rows)==931 save('refrigerated-warehouses-by-state',rows) # Count reference: distinct measures (not additive). measures=[ ('COUNT-01','2018','U.S.','Warehouse and storage buildings',1004000,'buildings','Survey estimate, rounded to nearest thousand; includes public rental storage','E18-B11','B11, All buildings, warehouse and storage column'), ('COUNT-02','2018','U.S.','Warehouse and distribution buildings excluding self-storage (approx.)',718000,'buildings','Sum of rounded estimates: 548,000 + 167,000 + 3,000. Total minus self-storage gives 719,000; both round to about 720,000.','E18-B16','B16, warehouse, distribution or shipping center, and refrigerated rows'), ('COUNT-07','2018','U.S.','Distribution or shipping center buildings',167000,'buildings','Rounded survey estimate','E18-B16','B16, Distribution or shipping center row'), ('COUNT-03','2021','Contiguous U.S.','Industrial warehouses over 20,000 square feet',149075,'properties','CoStar-based study, filtered to existing industrial warehouses built through 2021; not independently audited property list','KERR','Results; Methods: Warehouse locations and characteristics'), ('COUNT-04','2026-Q1','U.S.','Private-industry warehousing and storage (NAICS 493)',23848,'establishments','Preliminary; industry classification, not building count','BLS','Workplace Trends; extracted 2026-11-20'), ('COUNT-05','2026-Q1','U.S.','All four ownership categories, NAICS 493',24115,'establishments','Calculated sum; preliminary; not a building count','BLS','Workplace Trends; extracted 2026-11-20'), ('COUNT-06','2025-10-01','U.S.','Refrigerated food storage facilities within USDA survey scope',931,'facilities','USDA says figures are minimums; does not cover all refrigerated sites','USDA','pp. 4–5, 11–12')] rows=[] for rid,yr,geo,pop,val,unit,scope,src,loc in measures: ids=[src] rows.append(dict(row_id=rid,period=yr,geography=geo,population=pop,value=val,unit=unit,evidence_type='calculated' if rid in ('COUNT-02','COUNT-05') else 'source-reported',scope_note=scope,source_locator=loc,**meta(ids))) assert next(m[4] for m in measures if m[0]=='COUNT-05')==TABLES['warehouse-industry-establishments'][-1]['all_ownerships_sum'] save('warehouse-count-reference',rows) # Sources register. loc={ 'E03-A1':'2003 CBECS Table A1, Figure 1, all buildings including malls', 'E18-B16':'2018 CBECS B16, warehouse and storage and subtype rows; revised September 2022', 'E18-B1':'2018 CBECS B1, mean floor space per building', 'E12-B11':'2012 CBECS B11: national, floorspace size and region rows; May 2016', 'E12-B12':'2012 CBECS B12: national, floorspace size and region rows; May 2016', 'E18-B11':'2018 CBECS B11: national, floorspace size and region rows; revised September 2022', 'E18-B12':'2018 CBECS B12: national, floorspace size and region rows; revised September 2022', 'EIA-TYPES':'2018 warehouse and storage subtype and size summary (rounded proportions)', 'EIA-FAQ':'Definitions of building and commercial; survey limitations', 'EIA-LATEST':'Most recent CBECS reference year (2018)', 'KERR':'Kerr et al., Nature Communications 15, 6006 (2024), Results and Methods; doi:10.1038/s41467-024-50000-0', 'BLS':'NAICS 493 Workplace Trends; BLS extracted November 20, 2026', 'BLS-METHOD':'QCEW Q&A, establishment definition and industry classification', 'USDA':'Capacity of Refrigerated Warehouses 2025 Summary, February 9, 2026, pp. 4–7, 11–12', 'BLS-CALENDAR':'QCEW release calendar, Q2 2026 scheduled December 2, 2026', 'USDA-ARCHIVE':'Report release archive, February 9, 2026'} save('source-register',[dict(source_id=k,source_url=v,locator=loc[k],verified_on=D) for k,v in URL.items()]) # Standalone calculated findings with explicit arithmetic and references. findings=[ ('F01','2018','Over 100,000 sq ft: share of buildings (%)',pct(25,1004),'100 × (15+8+2)/1004',['E18-B11']), ('F02','2018','Over 100,000 sq ft: share of floorspace (%)',pct(6687,17483),'100 × (2056+2588+2043)/17483',['E18-B12']), ('F03','2018','1,001–10,000 sq ft: share of buildings (%)',pct(692,1004),'100 × (437+255)/1004',['E18-B11']), ('F04','2018','1,001–10,000 sq ft: share of floorspace (%)',pct(3294,17483),'100 × (1409+1885)/17483',['E18-B12']), ('F05','2012–2018','National warehouse/storage building count change (%)',change(796,1004),'100 × (1004−796)/796',['E12-B11','E18-B11']), ('F06','2012–2018','National warehouse/storage floorspace change (%)',change(13077,17483),'100 × (17483−13077)/13077',['E12-B12','E18-B12']), ('F07','2012–2018','Midwest warehouse/storage building count change (%)',change(163,307),'100 × (307−163)/163',['E12-B11','E18-B11']), ('F08','2025-10-01','Five states with highest USDA cold storage counts: share of facilities (%)',pct(sum(sorted([r['total_count'] for r in TABLES['refrigerated-warehouses-by-state']],reverse=True)[:5]),931),'100 × (106+94+62+56+52)/931',['USDA']), ('F09','2025-Q2–2026-Q1','Private NAICS 493 establishment change (%)',change(23190,23848),'100 × (23848−23190)/23190',['BLS']), ] findings.extend([ ('F10','2018','Building estimate excluding self-storage (buildings)',(548+167+3)*1000,'(548+167+3)*1000',['E18-B16']), ('F11','2018','Distribution center share of buildings (%)',pct(167,1004),'100*167/1004',['E18-B16']), ('F12','2018','Distribution center share of floor space (%)',pct(7998,17483),'100*7998/17483',['E18-B16']), ('F13','2018','Buildings over 100,000 square feet (buildings)',25000,'(15+8+2)*1000',['E18-B11']), ('F14','2018','Floor space over 100,000 square feet (square feet)',6687000000,'(2056+2588+2043)*1000000',['E18-B12']), ('F15','2003–2018','Building estimate change (%)',change(597,1004),'100*(1004-597)/597',['E03-A1','E18-B11']), ('F16','2003–2018','Floor space estimate change (%)',change(10078,17483),'100*(17483-10078)/10078',['E03-A1','E18-B12']), ('F17','2012–2018','West floor space estimate change (%)',change(3529,4006),'100*(4006-3529)/3529',['E12-B12','E18-B12']), ('F18','2026-Q1','All four ownership groups (establishments)',23848+250+7+10,'23848+250+7+10',['BLS']), ('F19','2025-10-01','Top five states by facility count: gross capacity share (%)',pct(399675+296620+303523+254076+300899,3987732),'100*(399675+296620+303523+254076+300899)/3987732',['USDA']), ('F20','2025-10-01','Usable share of gross capacity (%)',pct(3251415,3987732),'100*3251415/3987732',['USDA']), ]) save('refrigerated-warehouses-national',[dict(row_id='COLD-US',reference_date='2025-10-01',public_count=476,private_semiprivate_count=455,total_count=931,gross_capacity_cuft=3987732000,usable_capacity_cuft=3251415000,**meta(['USDA']))]) save('calculated-findings',[dict(row_id=k,period=t,measure=m,value=v,formula=f,**meta(s)) for k,t,m,v,f,s in findings]) assert pct(25,1004)==2.5 and pct(6687,17483)==38.2 assert sum(size[2018][0])==1004 and sum(size[2018][1])==17483 assert sum(size[2012][0])==796 # floor space independently rounded, may differ assert sum(r[3] for r in regions)==1004 assert sum(r[4] for r in regions)==17483 with (OUT/'warehouse-count-reference.json').open('w',encoding='utf-8') as f: json.dump({'name':'Uptime U.S. Warehouse Count and Footprint Reference','version':VERSION,'verified_on':D,'notes':['These source populations are not additive.','EIA values are rounded sample estimates; derived shares are descriptive, not precision estimates.','USDA withheld capacity is null, not zero.','Dates identify data periods, not current building counts.'],'tables':TABLES},f,indent=2,ensure_ascii=False,allow_nan=False) print('Rows per table:',{k:len(v) for k,v in TABLES.items()}) print('Total data rows excluding source register:',sum(len(v) for k,v in TABLES.items() if k!='source-register')) print('Findings:',[(r['row_id'],r['value']) for r in TABLES['calculated-findings']])