Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Standardizing CSV Column Headers

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Standardizing CSV Column Headers. Start with the requirements and the three tables on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

How would you standardize inconsistent column headers across multiple large CSV files?

Use the provided metadata tables to return each observed header after normalization and canonical mapping. Unmapped headers must remain visible for review.

Output

  1. One row per file and normalized header
  2. Columns: file_id, file_name, normalized_header, raw_headers, standardized_header, mapping_status, and header_count
  3. Include mapped and unmapped headers, ordered by file_id and normalized_header

Schema

csv_files
ColumnTypeDescription
file_idPKINTUnique identifier for a CSV file
file_nameVARCHAR(255)Source CSV file name
csv_headers
ColumnTypeDescription
raw_header_idPKINTUnique identifier for an observed header
file_idINTCSV file containing the header
header_nameVARCHAR(255)Header text exactly as observed in the file
header_mapping
ColumnTypeDescription
normalized_headerPKVARCHAR(255)Normalized header lookup key
canonical_headerVARCHAR(255)Approved standardized header name
Tablescsv_filescsv_headersheader_mapping
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results