[Python] polars.LazyFrame.sink_csv does not give CRLF line termination

Discussão em 'Python' iniciado por Stack, Novembro 25, 2025.

  1. Stack

    Stack Membro Participativo

    I have a Python file

    import polars as pl
    import requests
    from pathlib import Path

    url = "https://raw.githubusercontent.com/leanhdung1994/files/main/processedStep1_enwiktionary_namespace_0_43.ndjson"
    workingDir = r"E:\test"
    outNdjson = Path(workingDir, "wiktionary.ndjson")
    outTxt = Path(workingDir, "wiktionary.txt")

    # Download
    resp = requests.get(url)
    resp.raise_for_status()

    # Save
    with open(outNdjson, "wb") as f:
    f.write(resp.content)

    # Read with Polars
    lf = pl.scan_ndjson(outNdjson)
    lf.select("html").sink_csv(outTxt,
    include_header=False,
    maintain_order=True,
    quote_style="never",
    line_terminator="\r\n")


    My OS is Windows 11. Above, I use option line_terminator="\r\n" to get CRLF line termination. However, the resulted text file has LF line termination:

    [​IMG]

    Could you elaborate on this problem and how to fix it?

    Continue reading...

Compartilhe esta Página