Employee Skills Importer
This skill automates the process of importing employee skills from CSV files into a Supabase database. It parses the CSV, checks what already exists in the database, and generates idempotent SQL scripts to insert missing data.
Overview
The skill performs a 3-step process:
- Identify and insert missing skill categories - Extract categories from CSV headers, check database, generate INSERT script
- Identify and insert missing skills - Extract skills with their categories, check database, generate INSERT script
- Generate employee_skills INSERT script - Map employees by name, link skills, create final INSERT statements
CSV Format Requirements
The CSV must have:
- Row 1: Empty or metadata (ignored)
- Row 2: Skill category names spanning multiple columns
- Row 3+: Individual skill names (column headers, may span multiple rows due to line breaks)
- Employee data rows: Employee data with First Name, Last Name in first two columns, followed by skill experience values
Example structure:
,,,,,,.NET,,,,,Front-end,,,Java,,,
First Name,Last Name,Full Name,Unit,...,C#,ASP.net,MVC,...,JavaScript,HTML,CSS,...,Java,Spring,...
John,Doe,John Doe,Unit 1,...,5,4,3,...,6,6,5,...,0,0,...
Workflow
Step 1: Skill Categories
- Parse row 2 to extract unique category names
- Query the database to check existing categories:
SELECT name FROM skill_categories
- Generate idempotent INSERT for missing categories:
INSERT INTO skill_categories (name)
VALUES ('Category1'), ('Category2'), ('Category3')
ON CONFLICT (name) DO NOTHING;
Step 2: Skills
- Parse skill name rows and map to categories from row 2
- Query database for existing skills:
SELECT s.name, sc.name as category_name
FROM skills s
LEFT JOIN skill_categories sc ON s.category_id = sc.id
- For each skill to insert:
- Find the category_id using a subquery
- Generate idempotent INSERT:
INSERT INTO skills (name, category_id)
VALUES
('C#', (SELECT id FROM skill_categories WHERE name = '.NET')),
('JavaScript', (SELECT id FROM skill_categories WHERE name = 'Front-end'))
ON CONFLICT (name) DO NOTHING;
Step 3: Employee Skills
- Parse employee rows (first_name, last_name, skill values)
- Query employees table to get employee IDs:
SELECT id, first_name, last_name FROM employees
- For each employee, for each skill with non-zero experience:
- Look up employee_id by matching first_name + last_name
- Look up skill_id using subquery
- CRITICAL: Use TRIM() in WHERE clause to handle whitespace variations in database
- Generate INSERT:
INSERT INTO employee_skills (employee_id, skill_id, years_of_experience)
VALUES
(
(SELECT id FROM employees WHERE TRIM(first_name) = 'John' AND TRIM(last_name) = 'Doe'),
(SELECT id FROM skills WHERE name = 'C#'),
5
)
ON CONFLICT (employee_id, skill_id) DO UPDATE
SET years_of_experience = EXCLUDED.years_of_experience;
Important Notes
Database Schema
skill_categories table: id (uuid), name (text, unique)
skills table: id (uuid), name (text, unique), category_id (uuid FK to skill_categories)
employees table: id (uuid), first_name (text), last_name (text)
employee_skills table: id (uuid), employee_id (uuid FK), skill_id (uuid FK), years_of_experience (real)
Idempotency
All generated SQL scripts use ON CONFLICT clauses to ensure they can be run multiple times without errors:
- For categories and skills:
ON CONFLICT (name) DO NOTHING
- For employee_skills:
ON CONFLICT (employee_id, skill_id) DO UPDATE SET years_of_experience = EXCLUDED.years_of_experience
Data Handling
- Skip employees with zero or empty experience values for a skill
- Handle numeric experience values (can be integers or decimals like 0.5, 1.7, etc.)
- Clean up skill names by trimming whitespace and removing line breaks
- Skip rows where employee lookup fails (employee not found in database)
- Handle multi-line CSV cells properly
- CRITICAL: Deduplicate employee-skill pairs before generating SQL - Keep the highest years value when duplicates exist
- CRITICAL: Automatically correct employee name spellings - Use fuzzy matching to find and correct minor spelling differences (e.g., "Victoriia" → "Viktoriia")
- CRITICAL: Trim all employee names - Remove leading/trailing whitespace from all names
- CRITICAL: Use TRIM() in SQL WHERE clauses - Database may have extra spaces (e.g., "Yurii Solokha" with 3 spaces)
- CRITICAL: Skip employees with no match - If no close match found in database, exclude those records and report them
Error Prevention
- Always use subqueries for foreign key lookups rather than hardcoding UUIDs
- Validate that category names match between row 2 and skill lookups
- Report any employees from CSV not found in the database
- Report any skills that couldn't be mapped to categories
CRITICAL - Prevent Duplicate Key Violations:
- Before generating the employee_skills INSERT, deduplicate all records by (first_name, last_name, skill)
- When duplicates exist, keep the record with the highest years_of_experience value
- This prevents:
ON CONFLICT DO UPDATE command cannot affect row a second time
CRITICAL - Automatic Name Correction:
- Before generating SQL, validate ALL employees exist in the database
- For employees not found by exact match:
- Use fuzzy matching (Levenshtein distance or similar) to find close matches in database
- If a close match is found (e.g., "Victoriia" → "Viktoriia"), automatically use the database spelling
- If no close match is found, skip the employee entirely
- Generate a report showing:
- Employees with automatic corrections applied: "CSV name → Database name"
- Employees skipped (no match found): List with number of skills skipped
- This prevents:
null value in column "employee_id" violates not-null constraint
Output Format
The skill produces three SQL scripts plus one report file:
1_insert_categories.sql
-- Insert missing skill categories
INSERT INTO skill_categories (name)
VALUES ('.NET'), ('Front-end'), ('Java')
ON CONFLICT (name) DO NOTHING;
2_insert_skills.sql
-- Insert missing skills with category mapping
INSERT INTO skills (name, category_id)
VALUES
('C#', (SELECT id FROM skill_categories WHERE name = '.NET')),
('ASP.net', (SELECT id FROM skill_categories WHERE name = '.NET')),
('JavaScript', (SELECT id FROM skill_categories WHERE name = 'Front-end'))
ON CONFLICT (name) DO NOTHING;
3_insert_employee_skills.sql
-- Insert employee skills
-- Records have been deduplicated and filtered for valid employees only
-- Using TRIM() in WHERE clause to handle whitespace in database
INSERT INTO employee_skills (employee_id, skill_id, years_of_experience)
VALUES
(
(SELECT id FROM employees WHERE TRIM(first_name) = 'John' AND TRIM(last_name) = 'Doe'),
(SELECT id FROM skills WHERE name = 'C#'),
5
),
(
(SELECT id FROM employees WHERE TRIM(first_name) = 'John' AND TRIM(last_name) = 'Doe'),
(SELECT id FROM skills WHERE name = 'JavaScript'),
6
)
ON CONFLICT (employee_id, skill_id) DO UPDATE
SET years_of_experience = EXCLUDED.years_of_experience;
Execution Steps
When the user provides a CSV file:
Parse the CSV structure
- Read the file and validate format
- Extract category names from row 2
- Extract skill names from subsequent rows (handling multi-line cells)
- Map each skill to its category based on column positions
Query existing data from Supabase
- Fetch all existing skill_categories
- Fetch all existing skills with their categories
- Fetch all employees (id, first_name, last_name)
Generate Script 1: Categories
- Compare CSV categories against database
- Create INSERT statement for missing categories
- Save to file and present to user
Generate Script 2: Skills
- Compare CSV skills against database
- For missing skills, include category lookup subquery
- Create INSERT statement
- Save to file and present to user
Generate Script 3: Employee Skills
- Parse employee rows
- VALIDATE: Compare all CSV employees against database using exact matching
- FUZZY MATCH: For non-exact matches, find closest database employee using similarity algorithm
- Calculate similarity score for first_name and last_name separately
- If combined similarity is above threshold (e.g., 85%), automatically use database name
- Track all automatic corrections for reporting
- CORRECT: Replace CSV names with database names for matched employees
- FILTER: Skip employees with no close match found
- DEDUPLICATE: Remove duplicates by (employee, skill), keeping highest years value
- Generate INSERT statements using corrected employee names
- Generate report showing corrections and skipped employees
- Save SQL file and report to outputs directory
- Present both files to user
Present all files to the user
- Three SQL scripts (1_insert_categories.sql, 2_insert_skills.sql, 3_insert_employee_skills.sql)
- One report file (skipped_employees_report.txt) if any employees were skipped
- User can execute SQL scripts in order: 1 → 2 → 3
- User should review report to fix name mismatches if needed
Usage Example
User uploads CSV file and says:
"Parse this employee skills CSV and generate SQL insert scripts"
Skill responds:
- Analyzes the CSV structure
- Connects to Supabase SkillsSystem project
- Checks existing data in all three tables
- Generates three SQL files
- Reports summary (e.g., "Found 5 new categories, 23 new skills, generating inserts for 47 employees")
- Presents the three SQL files for download
Project Configuration
This skill is configured to work with the Supabase project:
- Project Name: SkillsSystem
- Project ID: ypibfhbklinkvybgotef
- Region: eu-central-1
The skill automatically connects to this project when executing queries.
Common Errors and Solutions
Error 1: "ON CONFLICT DO UPDATE command cannot affect row a second time"
Cause: Duplicate employee-skill pairs in the generated INSERT statement
Solution: The skill now deduplicates all records before generating SQL. If you see this error, it means deduplication was not performed.
Prevention: Always deduplicate by (first_name, last_name, skill) and keep the highest years value
Error 2: "null value in column 'employee_id' violates not-null constraint"
Cause: Employee from CSV not found in database (usually due to name spelling differences or whitespace issues)
Solution: The skill now:
- Automatically corrects spelling differences using fuzzy matching
- Trims all whitespace from names
- Uses TRIM() in SQL WHERE clauses to match database records with extra spaces
Common issues:
- Spelling variations: "Victoriia"↔"Viktoriia", "Karasyov"↔"Karasov"
- Extra whitespace in database: "Yurii Solokha" (3 spaces)
- Leading/trailing spaces
How it works:
- Compares CSV names against database using similarity algorithm
- If close match found (>83% similarity), automatically uses database spelling
- Trims all names before comparison
- Uses
TRIM(first_name) and TRIM(last_name) in SQL to handle database whitespace
- If no close match found, skips the employee and reports it
Result: This error should no longer occur as names are automatically corrected and whitespace is handled
Name Matching Algorithm
The skill uses the following approach:
- Try exact match first (first_name AND last_name)
- If no exact match, calculate similarity score using:
- Levenshtein distance or similar algorithm
- Handles common variations: "Victoriia"↔"Viktoriia", "Karasyov"↔"Karasov"
- If similarity > 83% threshold, accept as match
- If multiple close matches found, pick the closest one
- If no close match, skip the employee
- Always trim whitespace from both CSV and database names
- Use TRIM() in SQL queries to match records with extra spaces in database
1---
2name: employee-skills-importer
3description: Parse employee skills CSV files, identify skill categories and individual skills, look up employee IDs from an employees table, and generate idempotent SQL INSERT statements for skill_categories, skills, and employee_skills tables.
4metadata:
5 source: https://skillmd.com/skills/modbender/employee-skills-importer
6---
7
8# Employee Skills Importer
9
10This skill automates the process of importing employee skills from CSV files into a Supabase database. It parses the CSV, checks what already exists in the database, and generates idempotent SQL scripts to insert missing data.
11
12## Overview
13
14The skill performs a 3-step process:
151. **Identify and insert missing skill categories** - Extract categories from CSV headers, check database, generate INSERT script
162. **Identify and insert missing skills** - Extract skills with their categories, check database, generate INSERT script
173. **Generate employee_skills INSERT script** - Map employees by name, link skills, create final INSERT statements
18
19## CSV Format Requirements
20
21The CSV must have:
22- **Row 1**: Empty or metadata (ignored)
23- **Row 2**: Skill category names spanning multiple columns
24- **Row 3+**: Individual skill names (column headers, may span multiple rows due to line breaks)
25- **Employee data rows**: Employee data with First Name, Last Name in first two columns, followed by skill experience values
26
27Example structure:
28```
29,,,,,,.NET,,,,,Front-end,,,Java,,,
30First Name,Last Name,Full Name,Unit,...,C#,ASP.net,MVC,...,JavaScript,HTML,CSS,...,Java,Spring,...
31John,Doe,John Doe,Unit 1,...,5,4,3,...,6,6,5,...,0,0,...
32```
33
34## Workflow
35
36### Step 1: Skill Categories
37
381. Parse row 2 to extract unique category names
392. Query the database to check existing categories:
40 ```sql
41 SELECT name FROM skill_categories
42 ```
433. Generate idempotent INSERT for missing categories:
44 ```sql
45 INSERT INTO skill_categories (name)
46 VALUES ('Category1'), ('Category2'), ('Category3')
47 ON CONFLICT (name) DO NOTHING;
48 ```
49
50### Step 2: Skills
51
521. Parse skill name rows and map to categories from row 2
532. Query database for existing skills:
54 ```sql
55 SELECT s.name, sc.name as category_name
56 FROM skills s
57 LEFT JOIN skill_categories sc ON s.category_id = sc.id
58 ```
593. For each skill to insert:
60 - Find the category_id using a subquery
61 - Generate idempotent INSERT:
62 ```sql
63 INSERT INTO skills (name, category_id)
64 VALUES
65 ('C#', (SELECT id FROM skill_categories WHERE name = '.NET')),
66 ('JavaScript', (SELECT id FROM skill_categories WHERE name = 'Front-end'))
67 ON CONFLICT (name) DO NOTHING;
68 ```
69
70### Step 3: Employee Skills
71
721. Parse employee rows (first_name, last_name, skill values)
732. Query employees table to get employee IDs:
74 ```sql
75 SELECT id, first_name, last_name FROM employees
76 ```
773. For each employee, for each skill with non-zero experience:
78 - Look up employee_id by matching first_name + last_name
79 - Look up skill_id using subquery
80 - **CRITICAL: Use TRIM() in WHERE clause to handle whitespace variations in database**
81 - Generate INSERT:
82 ```sql
83 INSERT INTO employee_skills (employee_id, skill_id, years_of_experience)
84 VALUES
85 (
86 (SELECT id FROM employees WHERE TRIM(first_name) = 'John' AND TRIM(last_name) = 'Doe'),
87 (SELECT id FROM skills WHERE name = 'C#'),
88 5
89 )
90 ON CONFLICT (employee_id, skill_id) DO UPDATE
91 SET years_of_experience = EXCLUDED.years_of_experience;
92 ```
93
94## Important Notes
95
96### Database Schema
97- `skill_categories` table: id (uuid), name (text, unique)
98- `skills` table: id (uuid), name (text, unique), category_id (uuid FK to skill_categories)
99- `employees` table: id (uuid), first_name (text), last_name (text)
100- `employee_skills` table: id (uuid), employee_id (uuid FK), skill_id (uuid FK), years_of_experience (real)
101
102### Idempotency
103All generated SQL scripts use `ON CONFLICT` clauses to ensure they can be run multiple times without errors:
104- For categories and skills: `ON CONFLICT (name) DO NOTHING`
105- For employee_skills: `ON CONFLICT (employee_id, skill_id) DO UPDATE SET years_of_experience = EXCLUDED.years_of_experience`
106
107### Data Handling
108- Skip employees with zero or empty experience values for a skill
109- Handle numeric experience values (can be integers or decimals like 0.5, 1.7, etc.)
110- Clean up skill names by trimming whitespace and removing line breaks
111- Skip rows where employee lookup fails (employee not found in database)
112- Handle multi-line CSV cells properly
113- **CRITICAL: Deduplicate employee-skill pairs before generating SQL** - Keep the highest years value when duplicates exist
114- **CRITICAL: Automatically correct employee name spellings** - Use fuzzy matching to find and correct minor spelling differences (e.g., "Victoriia" → "Viktoriia")
115- **CRITICAL: Trim all employee names** - Remove leading/trailing whitespace from all names
116- **CRITICAL: Use TRIM() in SQL WHERE clauses** - Database may have extra spaces (e.g., "Yurii Solokha" with 3 spaces)
117- **CRITICAL: Skip employees with no match** - If no close match found in database, exclude those records and report them
118
119### Error Prevention
120- Always use subqueries for foreign key lookups rather than hardcoding UUIDs
121- Validate that category names match between row 2 and skill lookups
122- Report any employees from CSV not found in the database
123- Report any skills that couldn't be mapped to categories
124
125**CRITICAL - Prevent Duplicate Key Violations:**
1261. Before generating the employee_skills INSERT, deduplicate all records by (first_name, last_name, skill)
1272. When duplicates exist, keep the record with the highest years_of_experience value
1283. This prevents: `ON CONFLICT DO UPDATE command cannot affect row a second time`
129
130**CRITICAL - Automatic Name Correction:**
1311. Before generating SQL, validate ALL employees exist in the database
1322. For employees not found by exact match:
133 - Use fuzzy matching (Levenshtein distance or similar) to find close matches in database
134 - If a close match is found (e.g., "Victoriia" → "Viktoriia"), automatically use the database spelling
135 - If no close match is found, skip the employee entirely
1363. Generate a report showing:
137 - Employees with automatic corrections applied: "CSV name → Database name"
138 - Employees skipped (no match found): List with number of skills skipped
1394. This prevents: `null value in column "employee_id" violates not-null constraint`
140
141## Output Format
142
143The skill produces three SQL scripts plus one report file:
144
145**1_insert_categories.sql**
146```sql
147-- Insert missing skill categories
148INSERT INTO skill_categories (name)
149VALUES ('.NET'), ('Front-end'), ('Java')
150ON CONFLICT (name) DO NOTHING;
151```
152
153**2_insert_skills.sql**
154```sql
155-- Insert missing skills with category mapping
156INSERT INTO skills (name, category_id)
157VALUES
158 ('C#', (SELECT id FROM skill_categories WHERE name = '.NET')),
159 ('ASP.net', (SELECT id FROM skill_categories WHERE name = '.NET')),
160 ('JavaScript', (SELECT id FROM skill_categories WHERE name = 'Front-end'))
161ON CONFLICT (name) DO NOTHING;
162```
163
164**3_insert_employee_skills.sql**
165```sql
166-- Insert employee skills
167-- Records have been deduplicated and filtered for valid employees only
168-- Using TRIM() in WHERE clause to handle whitespace in database
169INSERT INTO employee_skills (employee_id, skill_id, years_of_experience)
170VALUES
171 (
172 (SELECT id FROM employees WHERE TRIM(first_name) = 'John' AND TRIM(last_name) = 'Doe'),
173 (SELECT id FROM skills WHERE name = 'C#'),
174 5
175 ),
176 (
177 (SELECT id FROM employees WHERE TRIM(first_name) = 'John' AND TRIM(last_name) = 'Doe'),
178 (SELECT id FROM skills WHERE name = 'JavaScript'),
179 6
180 )
181ON CONFLICT (employee_id, skill_id) DO UPDATE
182SET years_of_experience = EXCLUDED.years_of_experience;
183```
184
185## Execution Steps
186
187When the user provides a CSV file:
188
1891. **Parse the CSV structure**
190 - Read the file and validate format
191 - Extract category names from row 2
192 - Extract skill names from subsequent rows (handling multi-line cells)
193 - Map each skill to its category based on column positions
194
1952. **Query existing data from Supabase**
196 - Fetch all existing skill_categories
197 - Fetch all existing skills with their categories
198 - Fetch all employees (id, first_name, last_name)
199
2003. **Generate Script 1: Categories**
201 - Compare CSV categories against database
202 - Create INSERT statement for missing categories
203 - Save to file and present to user
204
2054. **Generate Script 2: Skills**
206 - Compare CSV skills against database
207 - For missing skills, include category lookup subquery
208 - Create INSERT statement
209 - Save to file and present to user
210
2115. **Generate Script 3: Employee Skills**
212 - Parse employee rows
213 - **VALIDATE: Compare all CSV employees against database using exact matching**
214 - **FUZZY MATCH: For non-exact matches, find closest database employee using similarity algorithm**
215 - Calculate similarity score for first_name and last_name separately
216 - If combined similarity is above threshold (e.g., 85%), automatically use database name
217 - Track all automatic corrections for reporting
218 - **CORRECT: Replace CSV names with database names for matched employees**
219 - **FILTER: Skip employees with no close match found**
220 - **DEDUPLICATE: Remove duplicates by (employee, skill), keeping highest years value**
221 - Generate INSERT statements using corrected employee names
222 - **Generate report showing corrections and skipped employees**
223 - Save SQL file and report to outputs directory
224 - Present both files to user
225
2266. **Present all files to the user**
227 - Three SQL scripts (1_insert_categories.sql, 2_insert_skills.sql, 3_insert_employee_skills.sql)
228 - One report file (skipped_employees_report.txt) if any employees were skipped
229 - User can execute SQL scripts in order: 1 → 2 → 3
230 - User should review report to fix name mismatches if needed
231
232## Usage Example
233
234User uploads CSV file and says:
235"Parse this employee skills CSV and generate SQL insert scripts"
236
237Skill responds:
2381. Analyzes the CSV structure
2392. Connects to Supabase SkillsSystem project
2403. Checks existing data in all three tables
2414. Generates three SQL files
2425. Reports summary (e.g., "Found 5 new categories, 23 new skills, generating inserts for 47 employees")
2436. Presents the three SQL files for download
244
245## Project Configuration
246
247This skill is configured to work with the Supabase project:
248- **Project Name**: SkillsSystem
249- **Project ID**: ypibfhbklinkvybgotef
250- **Region**: eu-central-1
251
252The skill automatically connects to this project when executing queries.
253
254## Common Errors and Solutions
255
256### Error 1: "ON CONFLICT DO UPDATE command cannot affect row a second time"
257**Cause:** Duplicate employee-skill pairs in the generated INSERT statement
258**Solution:** The skill now deduplicates all records before generating SQL. If you see this error, it means deduplication was not performed.
259**Prevention:** Always deduplicate by (first_name, last_name, skill) and keep the highest years value
260
261### Error 2: "null value in column 'employee_id' violates not-null constraint"
262**Cause:** Employee from CSV not found in database (usually due to name spelling differences or whitespace issues)
263**Solution:** The skill now:
2641. Automatically corrects spelling differences using fuzzy matching
2652. Trims all whitespace from names
2663. Uses TRIM() in SQL WHERE clauses to match database records with extra spaces
267
268**Common issues:**
269- Spelling variations: "Victoriia"↔"Viktoriia", "Karasyov"↔"Karasov"
270- Extra whitespace in database: "Yurii Solokha" (3 spaces)
271- Leading/trailing spaces
272
273**How it works:**
274- Compares CSV names against database using similarity algorithm
275- If close match found (>83% similarity), automatically uses database spelling
276- Trims all names before comparison
277- Uses `TRIM(first_name)` and `TRIM(last_name)` in SQL to handle database whitespace
278- If no close match found, skips the employee and reports it
279
280**Result:** This error should no longer occur as names are automatically corrected and whitespace is handled
281
282### Name Matching Algorithm
283The skill uses the following approach:
2841. Try exact match first (first_name AND last_name)
2852. If no exact match, calculate similarity score using:
286 - Levenshtein distance or similar algorithm
287 - Handles common variations: "Victoriia"↔"Viktoriia", "Karasyov"↔"Karasov"
2883. If similarity > 83% threshold, accept as match
2894. If multiple close matches found, pick the closest one
2905. If no close match, skip the employee
2916. Always trim whitespace from both CSV and database names
2927. Use TRIM() in SQL queries to match records with extra spaces in database