bool IDataParser.TryParse(FileInfo info, out TabularData tabularData) { tabularData = new TabularData().Default(info); IParser parser = _Factory.Create(info); parser.Parse(tabularData); return(tabularData.IsOkay); }
// POST: api/DataSet public async Task <Dataset> Post([FromUri] string datasetName, [FromUri] DataFormats dataFormat) { if (!Request.Content.IsMimeMultipartContent()) { throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); } using (var requestContent = await Request.Content.ParseMultipartAsync()) { if (!requestContent.Files.ContainsKey("file")) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var file = requestContent.Files["file"]; var fileName = file.Filename; string extension; if (!FileHelpers.TryGetExtension(fileName, out extension)) { throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); } var fileContent = file.File; var parser = parserFactory.Create(dataFormat); var metadata = new DatasetMetadata() { Name = "Test Data Set 1" }; var dataStore = GetDataStore(datasetName, dataFormat.GetFormat()); dataStore.Clear(); await dataStore.AddUnlabelledRow(parser.ExtractFeatureValues(fileContent, 500)); Dataset dataset = new Dataset() { Metadata = metadata }; return(dataset); } }