-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit_data.py
More file actions
30 lines (23 loc) · 969 Bytes
/
Copy pathsplit_data.py
File metadata and controls
30 lines (23 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
Split sensor_data.csv into smaller files by person
"""
import pandas as pd
import os
print("Loading sensor_data.csv...")
sensor_df = pd.read_csv("sensor_data.csv")
print(f"Loaded {len(sensor_df):,} rows")
# Create output directory
DATA_DIR = "sensor_data"
os.makedirs(DATA_DIR, exist_ok=True)
print(f"\nSplitting data by person into '{DATA_DIR}/'...")
# Get unique person IDs
person_ids = sorted(sensor_df["PERSON_ID"].unique())
print(f"Found {len(person_ids)} people")
# Save each person's data
for person_id in person_ids:
person_df = sensor_df[sensor_df["PERSON_ID"] == person_id]
person_file = os.path.join(DATA_DIR, f"person_{person_id:02d}.csv")
person_df.to_csv(person_file, index=False)
file_size_mb = os.path.getsize(person_file) / (1024 * 1024)
print(f" ✓ Person {person_id:2d}: {person_file} ({file_size_mb:.1f} MB, {len(person_df):,} rows)")
print(f"\n✅ Split complete! {len(person_ids)} files created in '{DATA_DIR}/'")