Extract and Normalize Timestamps from Multi-Format Log File
Beginner Mode

Start your terminal to use beginner mode.

Scenario

A log file contains entries with timestamps in multiple formats that need to be extracted and normalized for analysis.

Task

Write a Python script at /home/interview/extract_timestamps.py that reads /home/interview/application.log, uses regular expressions to extract all timestamps regardless of format, converts them to ISO 8601 format, and saves them to /home/interview/timestamps.txt (one timestamp per line).

Example

Input (application.log):

2026-02-10T14:30:45Z [ERROR] api.controller - Connection timeout
10/Feb/2026:15:45:30 +0000 [INFO] nginx.access - GET /api/users 200
Mon, 10 Feb 2026 16:20:15 +0000 [WARNING] system.auth - Failed login attempt

Expected output (timestamps.txt):

2026-02-10T14:30:45Z
2026-02-10T15:45:30Z
2026-02-10T16:20:15Z

Terminal requires a larger screen

Open this page on a desktop or tablet (≥ 768px) to launch the terminal and practice hands-on.

Linux Terminal Environment

Write and execute your solution in the terminal below.

Sign In

Track

Question Difficulty Company Access
Need more practice in this area? Explore more questions →