ramsesKouam
New member
- Joined
- Jan 18, 2022
- Messages
- 2
- Programming Experience
- Beginner
i would like to export some datas in a file in a web service. i used this package it exports datas as i defined in the code below :
	
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
but when i open spss file some characters appears, and i would like to make them disappears. here is a capture of the spss file content i generated
		
		
	
	
		 
	
as you see there is some characters i would like to remove, how can i do it? or is there any other method or package to use which is more effective than this one?
	
		
			
		
		
	
				
			
			
				spsslib package 's code to export data in spss:
			
		
		
		 var variables = new List<Variable>
{
    new Variable
    {
        Label = "Nombre de questionnaires envoyés",
        ValueLabels = new Dictionary<double, string>
                {
                    {1, "Label for 1"},
                    {2, "Label for 2"},
                },
        Name = "Nombre de questionnaires envoyés",
        PrintFormat = new OutputFormat(FormatType.F, 8, 2),
        WriteFormat = new OutputFormat(FormatType.F, 8, 2),
        Type = SpssLib.SpssDataset.DataType.Numeric,
        Width = 10,
        MissingValueType = MissingValueType.NoMissingValues
    },
    new Variable
    {
        Label = "Nombre de réponses",
        ValueLabels = new Dictionary<double, string>
                    {
                        {1, "this is 1"},
                        {2, "this is 2"},
                    },
        Name = "Nombre de réponses",
        PrintFormat = new OutputFormat(FormatType.F, 8, 2),
        WriteFormat = new OutputFormat(FormatType.F, 8, 2),
        Type = SpssLib.SpssDataset.DataType.Numeric,
        Width = 10,
        MissingValueType = MissingValueType.OneDiscreteMissingValue
    }
};
            // Set the one special missing value
            variables[1].MissingValues[0] = 999;
            // Default options
            var options = new SpssOptions();
            var listAnswers = await new Api.Survey.Models.Data.Services.SurveyReplyService(_context).getSurveyReplyBySurveyId(surveyId);
            var survey=await _context.Survey.FindAsync(surveyId);
            var surveytargetItems = await new Api.Survey.Models.Data.Services.SurveyTargetItemsService(_context).checkAllSurveyTargetItems(surveyId);
            using (FileStream fileStream = new FileStream("data.spss", FileMode.Create, FileAccess.Write))
            {
               // options.HeaderEncoding = Encoding.UTF8;
                options.DataEncoding= Encoding.UTF8;
              
                using (var writer = new SpssWriter(fileStream, variables, options))
                    {
                        // Create and write records
                        var newRecord = writer.CreateRecord();
                        newRecord[0] = Convert.ToDouble(surveytargetItems);
                        newRecord[1] = Convert.ToDouble(listAnswers);
                        writer.WriteRecord(newRecord);
                        /*
                        newRecord = writer.CreateRecord();
                        newRecord[0] = null;
                        newRecord[1] = 200d;
                        writer.WriteRecord(newRecord);
                        writer.EndFile();
                        */
                    }
              
            }as you see there is some characters i would like to remove, how can i do it? or is there any other method or package to use which is more effective than this one?
			
				Last edited: 
			
		
	
								
								
									
	
		
			
		
		
	
	
	
		
			
		
		
	
								
							
							 
	 
 
		 
 
		 
 
		