Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
::
with jsonlines.open('out.jsonl', mode='w') as writer:
writer.write(...)
:param file-like fp: name of the file to open
:param str mode: whether to open the file for reading (``r``),
writing (``w``) or appending (``a``).
:param **kwargs: additional arguments, forwarded to the reader or writer
"""
if mode not in {'r', 'w', 'a'}:
raise ValueError("'mode' must be either 'r', 'w', or 'a'")
fp = io.open(name, mode=mode + 't', encoding='utf-8')
if mode == 'r':
instance = Reader(fp, **kwargs)
else:
instance = Writer(fp, **kwargs)
instance._should_close_fp = True
return instance