Git Product home page Git Product logo

tdms's People

Contributors

dnoberon avatar mettekou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mettekou

tdms's Issues

TDMSValue from_path method do not exist

Hi,

I am starting with rust and labview and I am trying out this library, thanks for the work men!

Just a question about how to extract a value from a TDMSValue. In this particular case I need to extract the date to send it to a .csv file. I have this function:

fn extract_date(tdms_file: &TDMSFile, file: &mut File) -> std::io::Result<()> {
    let name = tdms_file.segments.get(0).unwrap().metadata.clone().unwrap();
    let obj = name
        .objects
        .iter()
        .find(|obj| obj.object_path == "/")
        .unwrap();
    // .collect();
    let date = obj
        .properties
        .iter()
        .find(|n| n.name == "DateTime")
        .unwrap()
        .value
        .clone();
    println!("extract date ---------->>> {:?}", date);
    Ok(())
}

date is of type TDMSValue, reading the docs I found that this struct has a method pub fn from_reader(...)
that I supose that is to extract that value from value depending on each type, but It seems that this function does not exists. I am not able to call this function.

image

Do you know what can be happening? any help is welcome. ๐Ÿ˜ƒ

Reading file in causes 'index out of bounds' error

I am attempting to read in a tdms file so I can perform calculations on the data contained within. The structure of the file is this:

test.tdms
    aux_data
        time [s] 
        distance [in]
        gps 
    mic_data
        time [s]
        mic 1
        mic 2 
        ... mic 12

Reading in this test.tdms file like so:

let file = match TDMSFile::from_path(Path::new("src/data/test.tdms")) {
        Ok(f) => f,
        Err(e) => panic!("{:?}", e),
    };

throws the following error. I fear that the error is due to the tiered structure of my data because reading in the provided (non-tiered) standard, raw, and big endian tdms files works fine.

thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 2', C:\...\.cargo\registry\src\github.com-1ecc6299db9ec823\tdms-0.2.5\src\segment.rs:114:75
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library\std\src\panicking.rs:584
   1: core::panicking::panic_fmt
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library\core\src\panicking.rs:142
   2: core::panicking::panic_bounds_check
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library\core\src\panicking.rs:84
   3: core::slice::index::impl$2::index<str>
             at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\slice\index.rs:250
   4: core::slice::index::impl$0::index
             at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\slice\index.rs:18
   5: alloc::vec::impl$16::index<str,usize,alloc::alloc::Global>
             at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\alloc\src\vec\mod.rs:2628
   6: tdms::segment::Segment::new<std::io::buffered::bufreader::BufReader<std::fs::File> >
             at C:\...\.cargo\registry\src\github.com-1ecc6299db9ec823\tdms-0.2.5\src\segment.rs:114
   7: tdms::TDMSFile::from_path
             at C:\...\.cargo\registry\src\github.com-1ecc6299db9ec823\tdms-0.2.5\src\lib.rs:124
   8: test::tdms_reader::open
             at .\src\tdms_reader.rs:11
   9: test::main
             at .\src\main.rs:15
  10: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
             at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\ops\function.rs:248

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.