-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind_checkin.py
More file actions
56 lines (44 loc) · 1.66 KB
/
find_checkin.py
File metadata and controls
56 lines (44 loc) · 1.66 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from __future__ import annotations
import argparse
import glob
import json
import os
def find_checkins(swarm_dir: str, pattern: str) -> list[tuple]:
"""Find check-ins matching a pattern in the given directory."""
if not os.path.exists(swarm_dir):
return []
json_files = glob.glob(os.path.join(swarm_dir, "checkins*.json"))
found = []
for file_path in json_files:
try:
with open(file_path, encoding="utf-8") as f:
data = json.load(f)
items = data.get("items", [])
for item in items:
venue_name = item.get("venue", {}).get("name", "")
if pattern.lower() in venue_name.lower():
created_at = item.get("createdAt")
found.append((created_at, venue_name))
except Exception as e:
print(f"Warning: failed to parse {file_path}: {e}")
return found
def main() -> None:
parser = argparse.ArgumentParser(description="Find specific Swarm check-ins.")
parser.add_argument(
"--dir",
default=r"G:\My Drive\Projects\Swarm Foursquare JFS 2026-02",
help="Swarm data directory",
)
parser.add_argument(
"--pattern", default="Holiday Inn Express Fremont", help="Venue name pattern to search for"
)
args = parser.parse_args()
results = find_checkins(args.dir, args.pattern)
if results:
print(f"Found {len(results)} check-ins for '{args.pattern}':")
for dt, name in sorted(results):
print(f" - {dt}: {name}")
else:
print(f"No check-ins found for '{args.pattern}'.")
if __name__ == "__main__":
main()