apache/superset · error · DatabaseUploadFailed

Error reading CSV file

Error message

Error reading CSV file

What it means

Catch-all DatabaseUploadFailed ('Error reading CSV file') raised in CSVReader._read_csv for any exception outside the recognized sets (not DatabaseUploadFailed, UnicodeDecodeError, ParserError, EmptyDataError, ValueError). Original exception is chained ('from ex') so server logs show the true cause — commonly OSError, KeyError from bad kwargs, dtype-related TypeError, or chunking/iterator errors in the chunked read path.

Source

Thrown at superset/commands/database/uploaders/csv_reader.py:471

            file.seek(0)
            detected_encoding = CSVReader._detect_encoding(file)
            if detected_encoding != encoding:
                kwargs["encoding"] = detected_encoding
                return CSVReader._read_csv(file, kwargs)
            raise DatabaseUploadFailed(
                message=_("Parsing error: %(error)s", error=str(ex))
            ) from ex
        except (
            pd.errors.ParserError,
            pd.errors.EmptyDataError,
            ValueError,
        ) as ex:
            raise DatabaseUploadFailed(
                message=_("Parsing error: %(error)s", error=str(ex))
            ) from ex
        except Exception as ex:
            raise DatabaseUploadFailed(_("Error reading CSV file")) from ex

    def file_to_dataframe(self, file: FileStorage) -> pd.DataFrame:
        """
        Read CSV file into a DataFrame

        :return: pandas DataFrame
        :throws DatabaseUploadFailed: if there is an error reading the file
        """
        rows_to_read = self._options.get("rows_to_read")
        chunk_size = current_app.config.get("READ_CSV_CHUNK_SIZE", 1000)

        use_chunking = rows_to_read is None or rows_to_read > chunk_size * 2

        kwargs = {
            "encoding": self._options.get("encoding", DEFAULT_ENCODING),
            "header": self._options.get("header_row", 0),
            "decimal": self._options.get("decimal_character", "."),
            "index_col": self._options.get("index_column"),

View on GitHub (pinned to f4587218dd)

Solutions

  1. Check the Superset server log for the chained 'from ex' cause — it identifies the real exception class
  2. Reduce the upload size or use rows_to_read to limit rows and confirm the file parses standalone
  3. For memory pressure, raise worker memory or split the CSV and upload in parts
  4. Reproduce with the same kwargs: pd.read_csv(file, **kwargs) locally

Example fix

head -n 1000 big.csv > sample.csv   # verify sample parses, then split upload
split -l 500000 big.csv part_  # upload parts sequentially
Defensive patterns

Strategy: try-catch

Try / catch

except DatabaseUploadFailed:
    log.exception("csv read failed")  # 'from ex' chain in logs identifies OSError/TypeError/MemoryError
    raise

Prevention

When it happens

Trigger: pd.read_csv raising OSError (unreadable/revoked stream), TypeError from incompatible options (e.g. dtype mapping problems), MemoryError on very wide/large CSVs, or chunked iteration failures when rows_to_read exceeds READ_CSV_CHUNK_SIZE-based chunking logic.

Common situations: Very large uploads exhausting memory before pandas can stream; options combinations the CSV reader builds internally (index_col, header handling) conflicting; uploads where the stream was consumed twice (seek on a non-seekable stream).

Related errors


AI-assisted analysis of apache/superset@f4587218dd (2026-08-14). Data as JSON: /api/errors/33ebe844f98d387a. Report an issue: GitHub.