/// <summary> /// Imports ascii from a memory stream into a table. Returns null (!) if nothing is imported. /// </summary> /// <param name="stream">The stream to import ascii from. Is not (!) closed at the end of this function.</param> /// <returns>The table representation of the imported text, or null if nothing is imported.</returns> public static Altaxo.Data.DataTable Import(System.IO.Stream stream) { Altaxo.Data.DataTable table = new Altaxo.Data.DataTable(); Altaxo.Serialization.Ascii.AsciiImporter importer = new Altaxo.Serialization.Ascii.AsciiImporter(stream); Altaxo.Serialization.Ascii.AsciiImportOptions options = importer.Analyze(20, new Altaxo.Serialization.Ascii.AsciiImportOptions()); if (options != null) { importer.ImportAscii(options, table); return(table); } else { return(null); } }
} // end of function ImportAscii /// <summary> /// Imports ascii from a string into a table. Returns null (!) if nothing is imported. /// </summary> /// <param name="text">The text to import as ascii.</param> /// <returns>The table representation of the imported text, or null if nothing is imported.</returns> public static Altaxo.Data.DataTable Import(string text) { System.IO.MemoryStream memstream = new System.IO.MemoryStream(); System.IO.TextWriter textwriter = new System.IO.StreamWriter(memstream); textwriter.Write(text); textwriter.Flush(); memstream.Position = 0; Altaxo.Data.DataTable table = new Altaxo.Data.DataTable(); Altaxo.Serialization.Ascii.AsciiImporter importer = new Altaxo.Serialization.Ascii.AsciiImporter(memstream); Altaxo.Serialization.Ascii.AsciiImportOptions options = importer.Analyze(20, new Altaxo.Serialization.Ascii.AsciiImportOptions()); if (options != null) { importer.ImportAscii(options, table); return(table); } else { return(null); } }