MCPcopy Create free account
hub / github.com/Kitware/VTK / ReadData

Method ReadData

IO/Infovis/vtkDelimitedTextReader.cxx:300–401  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

298
299//------------------------------------------------------------------------------
300int vtkDelimitedTextReader::ReadData(vtkTable* output_table)
301{
302 this->LastError = "";
303
304 if (!this->PedigreeIdArrayName)
305 {
306 vtkErrorMacro("You must specify a pedigree id array name");
307 return 1;
308 }
309
310 if (!this->ReadFromInputString && !this->FileName)
311 {
312 vtkWarningMacro("Cannot read from file without a file name set. Nothing read.");
313 return 1;
314 }
315
316 std::unique_ptr<std::istream> input_stream = this->OpenStream();
317 if (!input_stream)
318 {
319 vtkWarningMacro("Unable to open file, ReadData aborted.");
320 return 1;
321 }
322
323 this->ReadBOM(input_stream.get());
324
325 auto transCodec = vtkSmartPointer<vtkTextCodec>::Take(this->CreateTextCodec(input_stream.get()));
326
327 char tstring[2];
328 tstring[1] = '\0';
329 tstring[0] = this->StringDelimiter;
330 // don't use Set* methods since they change the MTime in
331 // RequestData() !!!!!
332 std::string fieldDelimiterCharacters = this->FieldDelimiterCharacters;
333 if (this->AddTabFieldDelimiter)
334 {
335 fieldDelimiterCharacters.push_back('\t');
336 }
337 this->UnicodeFieldDelimiters = fieldDelimiterCharacters;
338 this->UnicodeStringDelimiters = tstring;
339
340 if (nullptr == transCodec)
341 {
342 // should this use the locale instead??
343 return 1;
344 }
345
346 try
347 {
348 vtkDelimitedTextCodecIteratorPrivate iterator(this->SkippedRecords, this->MaxRecords,
349 this->UnicodeRecordDelimiters, this->UnicodeFieldDelimiters, this->UnicodeStringDelimiters,
350 this->UnicodeWhitespace, this->CommentCharacters, this->UnicodeEscapeCharacter,
351 this->HaveHeaders, this->MergeConsecutiveDelimiters, this->UseStringDelimiter,
352 this->DetectNumericColumns, this->ForceDouble, this->DefaultIntegerValue,
353 this->DefaultDoubleValue, output_table);
354
355 transCodec->ToUnicode(*input_stream, iterator);
356 iterator.ReachedEndOfInput();
357

Callers 2

RequestDataMethod · 0.95
RequestInformationMethod · 0.45

Calls 15

OpenStreamMethod · 0.95
ReadBOMMethod · 0.95
CreateTextCodecMethod · 0.95
TakeFunction · 0.85
SetPedigreeIdsMethod · 0.80
GetRowDataMethod · 0.80
GetColumnByNameMethod · 0.80
NewFunction · 0.50
stringClass · 0.50
getMethod · 0.45
push_backMethod · 0.45
ToUnicodeMethod · 0.45

Tested by

no test coverage detected