mikeobrien / TDMSReader

National Instruments TDMS File Reader for .NET and Mono.
MIT License
31 stars 32 forks source link

Issue reading strings #28

Open carlm83 opened 4 years ago

carlm83 commented 4 years ago

I have a large file that I'm trying to read. Sample is attached. All of the numeric values appear to read fine, but some of the strings are corrupted.

Here is the code I used to read the data:

using (var output = new System.IO.StreamWriter(System.IO.File.Create(@"C:\Carl\tdms_example.txt")) )
using (var tdms = new NationalInstruments.Tdms.File(openFileDialog1.FileName) )
{
    tdms.Open();

    output.WriteLine("Properties:");

    foreach ( var property in tdms.Properties )
    {
        output.WriteLine("  {0}: {1}", property.Key, property.Value);
    }

    output.WriteLine();

    foreach ( var group in tdms )
    {
        output.WriteLine("    Group: {0}", group.Name);

        foreach ( var property in group.Properties )
        {
            output.WriteLine("    {0}: {1}", property.Key, property.Value);
        }

        output.WriteLine();

        foreach ( var channel in group )
        {
            output.WriteLine("        Channel: {0}", channel.Name);

            foreach ( var property in channel.Properties )
            {
                output.WriteLine("        {0}: {1}", property.Key, property.Value);
            }

            output.WriteLine();
        }
    }
}

Attached is the output data. See "Channel: 1850-5 Lower Element" for an example of the data corruption.

The Excel importer add-in reads the TDMS file fine so I don't believe it is corrupted.

tdms_example.txt

String Issue Sample.zip

mettekou commented 4 years ago

@carlm83 Could you tell me which application on which operating system produced the TDMS file in question? Could you also tell me whether any of the strings contain non-ASCII characters?

carlm83 commented 4 years ago

LabView 2019 created the TDMS file. The computer it is x64 running on is Windows 10 Pro, version 10.0.18362 build 18362. There should be no non-ASCII characters.

carlm83 commented 4 years ago

@mettekou Any update on this? Thanks

mettekou commented 4 years ago

@carlm83 I have been able to reproduce the issue and have stepped through the code with your example TDMS file and channel path as an input. It seems the computed offset for the given channel's raw data is off by one byte. I have not been able to address this issue yet, as I do not fully understand its cause.

mettekou commented 3 years ago

@carlm83 If this issue is still relevant to you and your application can target .NET 5.0, note that FSharp.Data.Tdms reads your TDMS file just fine.

carlm83 commented 3 years ago

Thank you, Dylan, for letting me know about this. Yes, it is still of interest! I will give F# a try. Thanks again.

From: Dylan Meysmans notifications@github.com Sent: Sunday, January 10, 2021 11:04 AM To: mikeobrien/TDMSReader TDMSReader@noreply.github.com Cc: McDow, Carl cmcdow@hotwater.com; Mention mention@noreply.github.com Subject: Re: [mikeobrien/TDMSReader] Issue reading strings (#28)

This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.

@carlm83 [github.com]https://urldefense.com/v3/__https:/github.com/carlm83__;!!NJahUI48xw!F5KEfQyUG89BMaRM4zKx4fBBgjum_t1fE-MRmG9ss0fKIB7uiTa4ZGNkhXu8sXY$ If this issue is still relevant to you and your application can target .NET 5.0, note that FSharp.Data.Tdms [github.com]https://urldefense.com/v3/__https:/github.com/mettekou/FSharp.Data.Tdms__;!!NJahUI48xw!F5KEfQyUG89BMaRM4zKx4fBBgjum_t1fE-MRmG9ss0fKIB7uiTa4ZGNk6h0DBNk$ reads your TDMS file just fine.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub [github.com]https://urldefense.com/v3/__https:/github.com/mikeobrien/TDMSReader/issues/28*issuecomment-757499627__;Iw!!NJahUI48xw!F5KEfQyUG89BMaRM4zKx4fBBgjum_t1fE-MRmG9ss0fKIB7uiTa4ZGNkRjG1VW4$, or unsubscribe [github.com]https://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AOI2GHZ7VMF6V2G5PTOPEM3SZHFVJANCNFSM4KJFAX3Q__;!!NJahUI48xw!F5KEfQyUG89BMaRM4zKx4fBBgjum_t1fE-MRmG9ss0fKIB7uiTa4ZGNkealZ-0g$.

mettekou commented 3 years ago

@carlm83 Note that you do not have to switch to F# to use FSharp.Data.Tdms, it also provides an API for C#.