Repository: activeloopai/Hub
File: deeplake/api/dataset.py (Python)

Code before:
                            ...
                        ...
                    ...

            - Classes defined as sub-directories can be accessed at ``ds["test/labels"].info.class_names``.
            - Support for train and test sub directories is present under ``ds["train/images"]``, ``ds["train/labels"]`` and ``ds["test/images"]``, ``ds["test/labels"]``.
            - Mapping filenames to classes from an external file is currently not supported.
        """
        dest = convert_pathlib_to_string_if_needed(dest)
        feature_report_path(
            dest,
            "ingest_classification",
            {
                "Progressbar": progressbar,
                "Summary": summary,
            },
            token=token,
        )

        src = convert_pathlib_to_string_if_needed(src)

        if isinstance(src, str):
            if os.path.isdir(dest) and os.path.samefile(src, dest):
                raise SamePathException(src)

            if src.endswith(".csv") or src.endswith(".txt"):
                import pandas as pd  # type:ignore

                if not os.path.isfile(src):
                    raise InvalidPathException(src)
                source = pd.read_csv(src, quotechar='"', skipinitialspace=True)
                ds = dataset.ingest_dataframe(
                    source,
                    dest,
                    dest_creds=dest_creds,
                    progressbar=progressbar,
                    token=token,
                    **dataset_kwargs,
                )
                return ds

            if not os.path.isdir(src):
                raise InvalidPathException(src)

            if image_params is None:
                image_params = {}
            if label_params is None:
                label_params = {}

            if not image_params.get("sample_compression", None):
                images_compression = get_most_common_extension(src)

Review comment (suggestion):
```suggestion
            if src.lower().endswith(".csv") or src.endswith(".txt"):
```

Code after:
                            ...
                        ...
                    ...

            - Classes defined as sub-directories can be accessed at ``ds["test/labels"].info.class_names``.
            - Support for train and test sub directories is present under ``ds["train/images"]``, ``ds["train/labels"]`` and ``ds["test/images"]``, ``ds["test/labels"]``.
            - Mapping filenames to classes from an external file is currently not supported.
        """
        dest = convert_pathlib_to_string_if_needed(dest)
        feature_report_path(
            dest,
            "ingest_classification",
            {
                "Progressbar": progressbar,
                "Summary": summary,
            },
            token=token,
        )

        src = convert_pathlib_to_string_if_needed(src)

        if isinstance(src, str):
            if os.path.isdir(dest) and os.path.samefile(src, dest):
                raise SamePathException(src)

            if src.lower().endswith((".csv", ".txt")):
                import pandas as pd  # type:ignore

                if not os.path.isfile(src):
                    raise InvalidPathException(src)
                source = pd.read_csv(src, quotechar='"', skipinitialspace=True)
                ds = dataset.ingest_dataframe(
                    source,
                    dest,
                    dest_creds=dest_creds,
                    progressbar=progressbar,
                    token=token,
                    **dataset_kwargs,
                )
                return ds

            if not os.path.isdir(src):
                raise InvalidPathException(src)

            if image_params is None:
                image_params = {}
            if label_params is None:
                label_params = {}

            if not image_params.get("sample_compression", None):
                images_compression = get_most_common_extension(src)