Flat Files Data Guide – Filtering by exchange_symbol (Isolating Instruments from OHLCV Data)
Flat Files contain multiple instruments in a single file, even when scoped to one exchange. To analyze a specific asset (e.g., SWVL, TSM), you must filter by exchange_symbol.
This guide shows how to properly isolate and export specific instruments.
🧠 Understanding the Data Structure
Each row represents one instrument (symbol) for a given time period.
Sample Data
1id_exchange;exchange_symbol;time_period_start;time_period_end;time_open;time_close;price_open;price_high;price_low;price_close;volume_traded;trades_count
2IEXG;SWVL;2026-02-02T13:00:00.0000000;2026-02-02T13:01:00.0000000;2026-02-02T13:00:01.1326619;2026-02-02T13:00:59.9800186;3.03;3.19;2.97;3.17;4708;57
3IEXG;TSM;2026-02-02T13:00:00.0000000;2026-02-02T13:01:00.0000000;2026-02-02T13:00:01.1899337;2026-02-02T13:00:09.4006344;329.44;329.73;329.44;329.69;870;28
4IEXG;GLL;2026-02-02T13:00:00.0000000;2026-02-02T13:01:00.0000000;2026-02-02T13:00:01.1973889;2026-02-02T13:00:53.9836106;20.36;20.71;20.33;20.71;8325;6
5IEXG;SGOV;2026-02-02T13:00:00.0000000;2026-02-02T13:01:00.0000000;2026-02-02T13:00:01.4371872;2026-02-02T13:00:05.8175414;100.38;100.38;100.38;100.38;561;3
6IEXG;BMNR;2026-02-02T13:00:00.0000000;2026-02-02T13:01:00.0000000;2026-02-02T13:00:01.5840479;2026-02-02T13:00:01.5840479;22.61;22.61;22.61;22.61;100;1
7IEXG;SOXX;2026-02-02T13:00:00.0000000;2026-02-02T13:01:00.0000000;2026-02-02T13:00:02.0367595;2026-02-02T13:00:02.0367595;343.4;343.4;343.4;343.4;80;1🔑 Key Columns
id_exchange→ Exchange (e.g.,IEXG)exchange_symbol→ Instrument (e.g., SWVL, TSM, GLL)time_period_start/end→ Candle intervalprice_open/high/low/close→ OHLC pricesvolume_traded,trades_count→ activity
❗ Why Filtering is Helpful
Even though the file is:
1E-IEXG (one exchangeIt still contains multiple exchange_symbol values (SWVL, TSM, GLL, etc.)
👉 Without filtering, you are analyzing multiple instruments mixed together, which leads to incorrect results.
🔍 Step 1: Load the Data
🐍 Python (Pandas)
1import pandas as pd
2
3df = pd.read_csv("D-20260202.csv", delimiter=";")🎯 Step 2: Filter by a Single exchange_symbol
1filtered = df[df["exchange_symbol"] == "SWVL"]
2
3print(filtered)📁 Step 3: Save to a New File
1filtered.to_csv("SWVL.csv",index=False)👉 This creates a new file containing only SWVL data
🔢 Step 4: Filter Multiple Symbols
1filtered=df[df["exchange_symbol"].isin(["SWVL","TSM","GLL"])]Save multiple-symbol dataset
1filtered.to_csv("selected_symbols.csv",index=False)🔄 Step 5: (Optional) Automate Per-Symbol Export
Split the file into one file per symbol:
1for symbol in df["exchange_symbol"].unique():
2 subset = df[df["exchange_symbol"] == symbol]
3 subset.to_csv(f"{symbol}.csv", index=False)👉 Output:
1SWVL.csv
2TSM.csv
3GLL.csv
4SGOV.csv
5BMNR.csv
6SOXX.csv⚠️ Common Mistakes
❌ Forgetting quotes for strings
Wrong:
1df["exchange_symbol"]==SWVLCorrect:
1df["exchange_symbol"]=="SWVL"❌ Not saving the output
print(filtered)# only displays
👉 You must use:
to_csv()
❌ Wrong delimiter
Wrong:
1pd.read_csv("file.csv")Correct:
1pd.read_csv("file.csv",delimiter=";")💡 Best Practices
- Always filter before analysis
- Use
.isin()for multiple symbols - Save filtered outputs for reuse
- Validate results using
.unique()
🎯 Key Takeaway
Each Flat File is:
One exchange → Many symbols → One time interval
👉 Filtering by exchange_symbol is a helpful first step before any meaningful analysis.
