Skip to content

How to convert an untyped array value to a string #5377

Answered by Timmmm
Timmmm asked this question in Q&A
Discussion options

You must be logged in to vote

Ah ArrayFormatter was exactly what I was looking for, thanks! For reference for future people:

use arrow::{
    array::ArrayRef,
    util::display::{ArrayFormatter, FormatOptions},
};

pub fn value_string(column: &ArrayRef, row: usize) -> String {
    let options = FormatOptions::default();
    match ArrayFormatter::try_new(column.as_ref(), &options) {
        Ok(f) => f.value(row).to_string(),
        Err(e) => e.to_string(),
    }
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Timmmm
Comment options

Answer selected by Timmmm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants