Comparing Quarters
compare_metadata() diffs the metadata (D_*.TXT) files between two quarter directories so you can track schema changes over time.
Basic usage
import fcall
# Download two quarters
fcall.download_data(year=2014, month=9, dest="q3_2014/")
fcall.download_data(year=2025, month=9, dest="q3_2025/")
diffs = fcall.compare_metadata("q3_2014/", "q3_2025/")Return structure
compare_metadata() returns a dict with two keys:
"file_differences"
Describes changes in which metadata files exist and in what order:
fd = diffs["file_differences"]
fd["only_in_dir1"] # filenames present in dir1 but not dir2
fd["only_in_dir2"] # filenames present in dir2 but not dir1
fd["order_different"] # True if shared files appear in a different order"content_differences"
A dict keyed by filename (shared files only). Each value is a list of unified-diff lines for files that changed; files with identical content are omitted:
# Look at all of the content differences across all files
for filename, lines in diffs["content_differences"].items():
print(f"--- {filename} ---")
fcall.print_diff(lines)
# Or look at the content differences for a specific file
lines = diffs["content_differences"]["D_RI.TXT"]
fcall.print_diff(lines)Example: same quarter, no differences
Two downloads of the same quarter should show no differences:
diffs = fcall.compare_metadata("q3_2025_copy1/", "q3_2025_copy2/")
assert diffs["file_differences"]["only_in_dir1"] == []
assert diffs["file_differences"]["only_in_dir2"] == []
assert diffs["content_differences"] == {}Comparing a file directly
compare_files_content() lets you diff a single file between two directories:
from fcall import compare_files_content
diff = compare_files_content(
filename="D_RI.TXT",
dir1="q3_2014/",
dir2="q3_2025/",
)
fcall.print_diff(diff)