Reading a file with Polars that has been created as a TAD file and has sep='\t', lineterminator='\r'

588 views Asked by At

I can read a dataframe like this in pandas (it was originally a TAD file): pd.read_csv('/content/drive/MyDrive/Database Nencini/estrapola_articoli.csv', sep='\t', lineterminator='\r') How can I do it using polars library?

1

There are 1 answers

0
Pep_8_Guardiola On BEST ANSWER

Check the documentation here: scan_csv. There are separator and eol_char arguments that can be used if needed. Equivalent code:

import polars as pl

df = pl.scan_csv('/content/drive/MyDrive/Database Nencini/estrapola_articoli.csv',
                 separator='\t',
                 eol_char='\r',
                 )

I'd be tempted to try it without eol_char first.

If you want to read the whole file at once into memory (bad idea, your other post said it was huge), you can use read_csv() instead.