detectFormat static method

TCsvFileFormat detectFormat(
  1. String content
)

Auto-detects the data format (JSON, TSV, Semicolon, Pipe, CSV) from content.

Implementation

static TCsvFileFormat detectFormat(String content) {
  if (isJson(content)) {
    return TCsvFileFormat.json;
  }
  final delimiter = detectDelimiter(content);
  return switch (delimiter) {
    '\t' => TCsvFileFormat.tsv,
    ';' => TCsvFileFormat.semicolon,
    '|' => TCsvFileFormat.pipe,
    _ => TCsvFileFormat.csv,
  };
}