Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to convert Vec to row! macro #32

Open
kingmo888 opened this issue Aug 30, 2022 · 0 comments
Open

How to convert Vec to row! macro #32

kingmo888 opened this issue Aug 30, 2022 · 0 comments

Comments

@kingmo888
Copy link

kingmo888 commented Aug 30, 2022

Hello, I'm using your package to try to write something that calls rust code through python. It will be used to convert Python's pandas into a list and then save it as excel. Because pandas excel is too slow.
However, problems were encountered at the beginning,
I created a set of data (data<Vec<Vec<String>>>), like excel's rows,but I don't how to convert Vec to row! macro

data:
[ [ "a1", "b2", "c3", "d4", "e5", ], [ "11", "12", "13", "14", "15", ], [ "21", "22", "23", "24", "25", ], [ "31", "32", "33", "34", "35", ], ]

function is


fn build_data()->Vec<Vec<String>>{
    let s = "".to_string()
        + "a1,b2,c3,d4,e5\n"
        + "11,12,13,14,15\n"
        + "21,22,23,24,25\n"
        + "31,32,33,34,35";
    
    let s_v:Vec<String> = s.split('\n').map(|x| x.to_string()).collect();
    let mut v:Vec<Vec<String>> = Vec::new();
    for s1 in s_v{
        let s1:Vec<String> = s1.split(',').map(|x| x.to_string()).collect();
        v.push(s1);
    
    }
    v
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant