BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
devtrix
Obsidian | Level 7

Hi,

I am writing a .net ectd viewer app for a client int Windows Forms and one of the format it needs to read and display is .xpt file.I have installed the 32 bit & 64 bit interrop clients.  Any guidance is much appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
AlanC
Barite | Level 11

It 100% leads to a C# project but let me help clarify a bit.

 

To read the xpt format, using C# code, you can do it w/o any drivers. I am not sure what drivers you downloaded and, if they are allowed to be used in anothe rproject.

 

You can read the file natively since the layout is published. However, the numbers are expressed in IBM floating point format so you need to convert them to .NET. 

 

For the xpt file layout, see this article: https://documentation.sas.com/?docsetId=movefile&docsetTarget=p0ld1i106e1xm7n16eefi7qgj8m9.htm&docse...

 

When you read the file in, convert the numbers, from IBM mainframe layout, to doubles (I believe) using the article I sent you. 

 

If I get a chance, I will push out a .NET Core version of my C# code. When do you need to support it?

 

https://github.com/savian-net

View solution in original post

51 REPLIES 51
AlanC
Barite | Level 11

Format is published by SAS.

 

I wrote a C# reader/writer for it a number of years ago. Killer is the IBM floating point conversion. Look for my Code Project article on it if you need to go that route: https://www.codeproject.com/Articles/492449/Transform-between-IEEE-IBM-or-VAX-floating-point.

 

 

 

https://github.com/savian-net
devtrix
Obsidian | Level 7
Not sure what happened here. I am sorry, I dont understand the relevance of that project here. Plus it leads to a C++ project. I need to just be able to read .xpt file and display it. Thats it. Could you kindly clarify please.
AlanC
Barite | Level 11

It 100% leads to a C# project but let me help clarify a bit.

 

To read the xpt format, using C# code, you can do it w/o any drivers. I am not sure what drivers you downloaded and, if they are allowed to be used in anothe rproject.

 

You can read the file natively since the layout is published. However, the numbers are expressed in IBM floating point format so you need to convert them to .NET. 

 

For the xpt file layout, see this article: https://documentation.sas.com/?docsetId=movefile&docsetTarget=p0ld1i106e1xm7n16eefi7qgj8m9.htm&docse...

 

When you read the file in, convert the numbers, from IBM mainframe layout, to doubles (I believe) using the article I sent you. 

 

If I get a chance, I will push out a .NET Core version of my C# code. When do you need to support it?

 

https://github.com/savian-net
devtrix
Obsidian | Level 7
My apologies, it's been a while since I used CodeProject. I ended up clicking the original project. But I got it, thank you so much I will go over it now.
devtrix
Obsidian | Level 7

I accepted the solution too soon. I cant find anywhere a .xpt file is opened and read.  I can see where these converters can come in use.  But I dont see how the .xpt file is being imported to be read.  Could you clarify that please?  Thanks a bunch in advance.

 

AlanC
Barite | Level 11

No issues. I will get the actual code base prepared and pushed to nuget as a package. I don't believe I will release source code just yet but should be able to get a dll together.

https://github.com/savian-net
devtrix
Obsidian | Level 7
Thank you so much. Best regards!
AlanC
Barite | Level 11

It will be under Savian.SaviTransport in nuget. I just published it but this is my #1 publish on the public nuget. I expect to make a number of changes depending upon what you find. A simple test with shoes.xpt was successful.

https://github.com/savian-net
devtrix
Obsidian | Level 7

I installed the nuget in a .net core project. Since its not documented I am not sure what method to use.  For instance I have a d:\sample.xpt file.  How can I import this? What method can I use.  For ex: It would be simple to have something like Savian.SaviTransport.ImportXpt(d:\sample.xpt).
Also would it be too much to ask for .net 4.8 or compatible too?  I greatly appreciate your patience and help.
Thank you.

AlanC
Barite | Level 11

The package is documented. See here under documentation: https://www.nuget.org/packages/Savian.SaviTransport/#

 

This should be .NET Standard compatible. I can check on it some more (again, my first nuget publish). I checked the nupkg file (just rename to zip to see inside) and the dll is in there under lib. I am not familiar with nuget packaging but I assume it was done correctly by Visual Studio. Here is a simple example showing the new object, xptLib, that contains everything. The docs also show how to export the data into various formats.

 

var engine = new Savian.SaviTransport.Engine();
var options = new Savian.SaviTransport.Options()
{
    XptFile = _xptFile
};
var xptLib = engine.Process(options);

 

https://github.com/savian-net
devtrix
Obsidian | Level 7
I want to tell you how much I appreciate your efforts. This sounds exciting and I will try it out tomorrow. I will try to extract the nuget package and use the dll directly in .net 4.8 as well. I will keep you posted. Have a good night.
AlanC
Barite | Level 11

I updated the documentation on nuget and also switched the build from .NET Core 3.1 to .NET Standard 2.1. That should allow use in any .NET version that supports standard (includes Core and Framework). Hence, try the nuget package directly in Framework first before trying the dll directly. It should work.

 

See Hanselman's blog post for details: https://www.hanselman.com/blog/HowToReferenceANETCoreLibraryInWinFormsOrNETStandardExplained.aspx

 

 

https://github.com/savian-net
devtrix
Obsidian | Level 7
It worked in .net core 3.1 app flawlessly. However, in .net 4.8 the nuget package is not installing the .dll; just the .xml file. When I simply added it as a reference from an nuget extracted path, it bombs out saying it cant find a dependency as soon as it hits the first statement "var engine = new Savian.SaviTransport.Engine();".
AlanC
Barite | Level 11

Did you download the latest? It has dependencies on System.Text.Json (standard) and System.ComponentModel.Annotations (standard) but they should have been bundled. Try adding them and see if that works. If so, i can update the build and somehow force the integration.

 

Also, it might better to work out the details offline and then post that it is operational. Feel free to reach out via the nuget channel and then we can let everyone know once it is operational. 

https://github.com/savian-net

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 51 replies
  • 7630 views
  • 13 likes
  • 5 in conversation