| File | Date | Author | Commit |
|---|---|---|---|
| .gitignore | 2026-02-17 |
|
[99bda3] Initial commit |
| LICENSE | 2026-02-17 |
|
[99bda3] Initial commit |
| PD Lines TimeTable - Down2.csv | 2026-02-17 |
|
[99bda3] Initial commit |
| PD Lines TimeTable - Down3.csv | 2026-02-17 |
|
[99bda3] Initial commit |
| PD Lines TimeTable - Up2.csv | 2026-02-17 |
|
[99bda3] Initial commit |
| PD Lines TimeTable - Up3.csv | 2026-02-17 |
|
[99bda3] Initial commit |
| README.md | 2026-02-17 |
|
[99bda3] Initial commit |
| pd_timetable_final.html | 2026-02-17 |
|
[99bda3] Initial commit |
| pd_timetable_final.png | 2026-02-17 |
|
[99bda3] Initial commit |
| plot_timetable.py | 2026-02-17 |
|
[99bda3] Initial commit |
A Python utility for generating visual timetable diagrams from CSV data, showing train movements across stations over time as distance-vs-time plots.
pip install pandas matplotlib plotly
python plot_timetable.py "Down.csv" "Up.csv" --out timetable.png
python plot_timetable.py "Down.csv" "Up.csv" --plotly --out timetable.html
python plot_timetable.py <csv1> <csv2> ... [options]
Provide one or more CSV files containing timetable data.
--distance-col N - Distance column (1-based, default: 1 → column A)--stop-name-col N - Stop name column (1-based, default: 2 → column B)--event-col N - ARR/DEP marker column (1-based, default: 4 → column D)--train-code-row N - Row containing train codes (1-based, default: 4)--train-time-col-start N - First train time column (1-based, default: 5 → column E)--start-row N - First stop row (1-based, default: 20)--end-row N - Last stop row (1-based, default: 38)--row-range RANGE - Per-file ranges like filename=start-end or bare ranges in CSV order--row-range-from-file - Read row ranges from cell A1 of each CSV (format: start-end)--out FILE - Output filename (default: timetable.png)--plotly - Generate interactive HTML instead of PNG--prefix-filename - Prefix train codes with source filename to avoid collisionsRow 1: Optional row-range metadata (if using --row-range-from-file)
Row 2-3: Header information
Row 4: Train codes (configurable with --train-code-row)
Row 5+: Stop data
Columns:
A: Distance (configurable with --distance-col)
B: Stop name (configurable with --stop-name-col)
C: Additional info
D: ARR/DEP markers (configurable with --event-col)
E+: Train times (configurable with --train-time-col-start)
19-36,,,,,,
Distance,Stop Name,Info,Event,Train 1,Train 2,Train 3
0.0,Station A,,ARR,08:00,09:15,10:30
0.0,Station A,,DEP,08:05,09:20,10:35
5.5,Station B,,ARR,08:25,09:40,10:55
5.5,Station B,,DEP,08:30,09:45,11:00
Accepts multiple formats:
5:40a or 5:40p (converts to AM/PM)17:40 (24-hour)6:10:00 PM (12-hour with seconds)- or blank for no stoppython plot_timetable.py "Down3.csv" "Up3.csv" \
--distance-col 2 \
--stop-name-col 3 \
--row-range-from-file \
--plotly \
--out timetable.html
python plot_timetable.py "Down.csv" "Up.csv" \
--row-range "Down.csv=20-35" \
--row-range "Up.csv=18-33" \
--out timetable.png
python plot_timetable.py "Down.csv" "Up.csv" \
--row-range "20-35" \
--row-range "18-33" \
--out timetable.png
The plotter uses train codes to automatically assign colors, markers, and line styles:
Example codes:
2L00 → Color for "2", marker for "L", solid line (passenger)4P00 → Color for "4", marker for "P", dotted line (freight)6B00 → Color for "6", marker for "B", dashed line (ECS/parcels)0X00 → Color for "0", marker for "X", dashed line (light engine)Station Names Truncated? The script automatically adjusts left margin based on label length. If truncation occurs, try using shorter station names in your CSV.
Missing Endpoint Stops? Ensure your CSV has either ARR or DEP markers, or at least one time entry for endpoint stations. The script uses fallback rows when explicit markers are missing.
Lines Not Connecting? The script links arrivals to previous departures in time order. Verify your time formats are consistent and parseable.
Duplicate Train Codes? By default, duplicates are auto-suffixed as (2), (3), etc. Use --prefix-filename to prefix with source filename instead.
--train-code-row matches your CSV--train-time-col-start points to first train column5:40a, 17:40, 6:10:00 PM- or leave blank for no stopThis utility is provided as-is for timetable visualization purposes.