public void CreateDocument()
 {
     if (File.Exists(TestBase.DisposableFilename))
     {
         File.Delete(TestBase.DisposableFilename);
     }
     try
     {
         using (SpssDataDocument doc = SpssDataDocument.Create(TestBase.DisposableFilename))
         {
             Assert.Equal(SpssFileAccess.Create, doc.AccessMode);
             Assert.False(doc.IsClosed, "Newly opened document claims to be closed.");
             Assert.Equal(TestBase.DisposableFilename, doc.Filename);
             Assert.True(doc.IsAuthoringDictionary, "Newly created data file should be in dictionary authoring mode.");
             Assert.True(doc.IsCompressed, "Newly created documents should default to being Compressed.");
         }
     }
     finally
     {
         if (File.Exists(TestBase.DisposableFilename))
         {
             File.Delete(TestBase.DisposableFilename);
         }
     }
 }
Exemple #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("SPSS file writing demo:");
            if (File.Exists("example.sav"))
            {
                File.Delete("example.sav");
            }
            CreateExampleDocument();

            Console.WriteLine("Exporting a DataTable demo... (the source code is interesting)");
            DataTable dt = SpssConvert.ToDataTable(GetFileName());

            if (File.Exists("example2.sav"))
            {
                File.Delete("example2.sav");
            }
            SpssConvert.ToFile(dt, "example2.sav", MetaDataCallback);

            Console.WriteLine("SPSS dictionary copying demo:");
            if (File.Exists("example3.sav"))
            {
                File.Delete("example3.sav");
            }
            using (SpssDataDocument doc = SpssDataDocument.Create("example3.sav", GetFileName())) {
                PrintMetaData(doc);
            }

            Console.WriteLine("Demo concluded.  Press any key to end.");
            Console.ReadKey();
        }
        public void Write(String filename)
        {
            _doc = SpssDataDocument.Create(filename);

            CreateColumnMetaData(_doc, _columnCodes); //_columnDefinitions);
            CreateRows(_doc, _journalAnswersCollection);
            Result = _doc;
        }
Exemple #4
0
 private static void CreateExampleDocument()
 {
     using (SpssDataDocument doc = SpssDataDocument.Create("example.sav")) {
         CreateMetaData(doc);
         CreateData(doc);
     }
     Console.WriteLine("Examine example.sav for the results.");
     Console.WriteLine("SPSS file reading demo:");
     using (SpssDataDocument doc = SpssDataDocument.Open(GetFileName(), SpssFileAccess.Read)) {
         PrintMetaData(doc);
         PrintData(doc);
     }
 }
Exemple #5
0
        public static void GenerateSPSSDocument(List <Test> tests, string fileName = "ALLdata.sav")
        {
            fileName = DataGenerator.DataDirectory + fileName;

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            using (SpssDataDocument doc = SpssDataDocument.Create(fileName)) {
                CreateMetaData(doc);
                foreach (var test in tests)
                {
                    ParseTest(doc, test);
                }
            }
        }
Exemple #6
0
 public TestBase()
 {
     try
     {
         docRead   = SpssDataDocument.Open(GoodFilename, SpssFileAccess.Read);
         docAppend = SpssDataDocument.Open(AppendFilename, SpssFileAccess.Append);
         if (File.Exists(DisposableFilename))
         {
             File.Delete(DisposableFilename);
         }
         docWrite = SpssDataDocument.Create(DisposableFilename);
     }
     catch
     {
         docRead?.Dispose();
         docAppend?.Dispose();
         docWrite?.Dispose();
         throw;
     }
 }