def tsv_escape ( x : Any ) -> str : if x is None : return "" x = str ( x ) return x . replace ( "\t" , "\\t" ) . replace ( "\n" , "\\n" )
python csv replacing nulls with empty string
Escape data for tab - separated value ( TSV ) format .
def tsv_escape(x: Any) -> str:
    """
    Escape data for tab-separated value (TSV) format.
    """
    if x is None:
        return ""
    x = str(x)
    return x.replace("\t", "\\t").replace("\n", "\\n")