Mearthy
Mearthy9mo ago

Help with Base64 - python - polars column Names

Hey guys I am trying to figure out if I am doing this right. I have figured out to how to read and decode a csv file in python, but when I return a polars dataframe it is missing columns names and just giving me numbers. Am I missing something?
No description
3 Replies
Mearthy
Mearthy9mo ago
Test-Code
import base64
import polars as pl

def main(base_str):
base64_string = base_str
sample_string_bytes = base64.b64decode(base64_string)
#return sample_string_bytes.decode()
return pl.read_csv(sample_string_bytes)
import base64
import polars as pl

def main(base_str):
base64_string = base_str
sample_string_bytes = base64.b64decode(base64_string)
#return sample_string_bytes.decode()
return pl.read_csv(sample_string_bytes)
Faton
Faton9mo ago
Hi @Mearthy, I think you're missing a toDicts to have an array of objects:
import polars as pl

def main(base_str: bytes = bytes(0)):
csv = pl.read_csv(base_str)
return csv.to_dicts()
import polars as pl

def main(base_str: bytes = bytes(0)):
csv = pl.read_csv(base_str)
return csv.to_dicts()
Mearthy
Mearthy9mo ago
Okay I was just overthinking things. Thank you so much