Note
This piece of code was generated by GPT-4.
from pathlib import Path
import json
def load_jsonl_limit(path, limit=None):
with Path(path).open("r") as f:
for idx, line in enumerate(f):
if limit is not None and idx >= limit:
break
yield json.loads(line)