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

No data is available for encoding 1252. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. #35

Open
deepak206 opened this issue Mar 25, 2020 · 2 comments

Comments

@deepak206
Copy link

deepak206 commented Mar 25, 2020

I am trying to read the .sav file and getting this issue.

No data is available for encoding 1252. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.

using (FileStream fileStream = new FileStream("{file_path}/test.sav", FileMode.Open, FileAccess.Read))
            {                
                SpssReader spssDataset = new SpssReader(fileStream);
                foreach (var variable in spssDataset.Variables)
                {
                    Console.WriteLine("{0} - {1}", variable.Name, variable.Label);

                    foreach (KeyValuePair<double, string> label in variable.ValueLabels)
                    {
                        Console.WriteLine(" {0} - {1}", label.Key, label.Value);
                    }
                }

Please let me know what I am doing wrong

@fcproj
Copy link

fcproj commented Sep 14, 2020

Hi, I am facing the same issue "No data is available for encoding 1252". Any news on this topic?

@przemasd
Copy link

przemasd commented Mar 16, 2022

Hi @fcproj & @deepak206
as for me, help add before creating a new instance of SpssReader register provider for encoding

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

you must first install https://www.nuget.org/packages/System.Text.Encoding.CodePages/

using (FileStream fileStream = new FileStream("{file_path}/test.sav", FileMode.Open, FileAccess.Read))
{         
    Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);       
    SpssReader spssDataset = new SpssReader(fileStream);
    foreach (var variable in spssDataset.Variables)
    {
        Console.WriteLine("{0} - {1}", variable.Name, variable.Label);

        foreach (KeyValuePair<double, string> label in variable.ValueLabels)
        {
            Console.WriteLine(" {0} - {1}", label.Key, label.Value);
        }
    }
}

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

3 participants