irregular-excel-parsing
यह क्या करती है
यह स्किल उन Excel फ़ाइलों को पढ़ने का तरीका बताती है, जिनमें कॉलम के शीर्षक पहली पंक्ति में नहीं होते, या पहले शीर्षक और मेटाडेटा की पंक्तियाँ आती हैं। यह उन विश्लेषकों के लिए है जो अनियमित लेआउट वाली रिपोर्ट के साथ काम करते हैं।
कब इस्तेमाल करें
- ✓जब Excel शीट में हेडर कुछ पंक्तियाँ नीचे हों, शीर्षक या मेटाडेटा पंक्तियों के बाद।
- ✓जब हेडर क्षेत्र में मर्ज की हुई सेल की वजह से सामान्य पढ़ाई विफल हो।
- ✓जब मुझे पहले से नहीं पता कि कॉलम के हेडर कौन सी पंक्ति में हैं।
Skill का लिंक
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/irregular-excel-parsing/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरी Excel रिपोर्ट में तालिका से पहले कई शीर्षक पंक्तियाँ हैं। कृपया पता लगाइए कि असली हेडर कहाँ हैं, और डेटा सही तरीके से लोड कीजिए।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
AI पूरी शीट बिना किसी हेडर पंक्ति मानकर पढ़ता है, पंक्तियों में ज्ञात कॉलम नाम या पैटर्न खोजता है, मिली हुई पंक्ति को हेडर सेट करता है, और उसके नीचे का डेटा लोड करता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Irregular Excel File Parsing
Use this skill when you encounter Excel files where standard pandas.read_excel() fails due to:
- Headers not in row 0 (6-9+ header rows common)
- Merged cells in header area
- Unknown or inconsistent header row positions
- Multiple title/metadata rows before actual data
Step-by-Step Instructions
Step 1: Read Excel Without Headers
First, read the entire sheet with header=None to get raw data:
import pandas as pd
# Read all data without assuming header position
df_raw = pd.read_excel('filename.xlsx', sheet_name='Sheet1', header=None)
Step 2: Scan Rows to Find Header Pattern
Search for the actual header row by looking for distinctive patterns:
def find_header_row(df):
"""Find header row by pattern-matching common column identifiers."""
header_patterns = [
r'Store ID',
r'ID\d{4}', # ID followed by 4 digits
r'Week \d+',
r'Date',
r'Store',
r'Product',
r'ID'
]
for row_idx in range(len(df)):
row_values = df.iloc[row_idx].astype(str).str.lower()
for pattern in header_patterns:
if row_values.str.contains(pattern, case=False, regex=True).any():
return row_idx
# Fallback: return first non-empty row
for row_idx in range(len(df)):
if df.iloc[row_idx].notna().sum() > 0:
return row_idx
return 0
header_row = find_header_row(df_raw)
Step 3: Extract and Clean Headers
Extract the header row and clean column names:
# Extract header row
headers = df_raw.iloc[header_row].tolist()
# Clean headers: convert to string, strip whitespace, handle NaN
clean_headers = []
for h in headers:
if pd.isna(h) or str(h).strip() == '':
clean_headers.append(f'col_{len(clean_headers)}')
else:
clean_headers.append(str(h).strip())
# Handle duplicate headers by adding suffix
from collections import Counter
header_counts = Counter(clean_headers)
final_headers = []
for h in clean_headers:
if header_counts[h] > 1:
final_headers.append(f"{h}_{header_counts[h]}")
header_counts[h] -= 1
else:
final_headers.append(h)
Step 4: Extract Data Rows
Extract data starting from the row after headers:
# Get data rows (everything after header)
data_df = df_raw.iloc[header_row + 1:].copy()
data_df.columns = final_headers
# Reset index
data_df = data_df.reset_index(drop=True)
# Remove completely empty rows
data_df = data_df.dropna(how='all')
Step 5: Validate and Clean Data
Perform basic validation and type conversion:
# Identify ID columns and preserve as string
for col in data_df.columns:
if 'id' in col.lower() or 'code' in col.lower():
data_df[col] = data_df[col].astype(str).str.strip()
# Convert numeric columns
numeric_cols = data_df.select_dtypes(include=['float64', 'int64']).columns
for col in numeric_cols:
data_df[col] = pd.to_numeric(data_df[col], errors='coerce')
# Remove rows with invalid critical data
if 'Store ID' in data_df.columns:
data_df = data_df[data_df['Store ID'].notna() & (data_df['Store ID'] != '')]
Complete Example Function
def parse_irregular_excel(filepath, sheet_name=0):
"""Parse Excel file with unknown/irregular header structure."""
import pandas as pd
import re
from collections import Counter
# Step 1: Read raw
df_raw = pd.read_excel(filepath, sheet_name=sheet_name, header=None)
# Step 2: Find header row
patterns = [r'Store ID', r'ID\d{4}', r'Week', r'Date', r'Store']
header_row = 0
for idx in range(min(15, len(df_raw))): # Check first 15 rows
row_str = ' '.join(df_raw.iloc[idx].astype(str))
for pattern in patterns:
if re.search(pattern, row_str, re.IGNORECASE):
header_row = idx
break
# Step 3: Extract headers
headers = [str(h).strip() if pd.notna(h) else f'col_{i}'
for i, h in enumerate(df_raw.iloc[header_row])]
# Handle duplicates
counts = Counter(headers)
final_headers = []
for h in headers:
if counts[h] > 1:
final_headers.append(f"{h}_{counts[h]}")
counts[h] -= 1
else:
final_headers.append(h)
# Step 4: Extract data
data_df = df_raw.iloc[header_row + 1:].copy()
data_df.columns = final_headers
data_df = data_df.dropna(how='a
अक्सर पूछे जाने वाले सवाल
कौन सी लाइब्रेरी इस्तेमाल होती है?
उदाहरणों में शीट पढ़ने के लिए pandas इस्तेमाल होता है, और हेडर पंक्ति मिलने के बाद सेट की जाती है।
अगर कोई पैटर्न मेल न खाए तो?
गाइड डेटा वाली पहली पंक्ति को फ़ॉलबैक के रूप में लेती है।
डिफ़ॉल्ट रीड क्यों नहीं?
डिफ़ॉल्ट मान लेता है कि हेडर पहली पंक्ति में हैं, जो इन लेआउट के लिए विफल होता है।
जानकारी
लेखक का मूल विवरण
Handle Excel files with irregular headers, merged cells, and unknown header row positions using pattern-matching and index-based extraction.
repo: HKUDS/AgentPilot
लोकप्रियता
- GitHub स्टार
- 7.8k
- रैंकिंग में स्थान
- #12894
- लाइसेंस
- MIT
- अपडेट की गई
- 1/11/2026
कमेंट
- …
इस repository की और skills
agentpilot
7.8kआपके एजेंट को AgentPilot से प्रोजेक्ट को चरण-दर-चरण सुधारने में मदद करती है, जिसमें बदलाव सुझाए, परखे और स्कोर किए जाते हैं।
openspace
7.8kआपके एजेंट को OpenSpace सेट करने में मदद करती है, जो एजेंट स्किल्स सहेजता और वापस लाता है, और MCP के ज़रिए आपके AI ऐप से जुड़ता है।
rsi-arena
7.8kआपके एजेंट को AIME और Terminal-Bench जैसे मानक AI बेंचमार्क टेस्ट सेट करने और चलाने में मदद करती है, ताकि सुधार के तरीकों की तुलना हो सके।
experiment-guide
7.8kआपके एजेंट को छोटे प्रयोग बनाने, उनके नतीजे पढ़ने और जाँच के दौरान उपयोगी निष्कर्ष लिखने में मदद करती है।
मिलती-जुलती skills
gitcrawl
394kयह आपके एजेंट को GitHub issues और pull requests के सेव आर्काइव में खोजने, मिलते-जुलते मामलों को समूह में रखने और लाइव स्थिति जांचने देती है।
slacrawl
394kयह आपके एजेंट को स्थानीय Slack आर्काइव में संदेश खोजने और गिनने, उसकी ताज़गी जांचने और ज़रूरत पड़ने पर उसे ताज़ा करने देती है।
goplaces
394kयह आपके एजेंट को Google Places से जगहें खोजने, उनका विवरण और समीक्षाएं पाने, और जगह के नाम हल करने में मदद करती है, स्क्रिप्ट के लिए JSON आउटपुट के साथ।