Repository: langchain
Issue: Cannot load Vietnamese UTF-8 CSV with UnstructuredFileLoader 
Labels: Ɑ: doc loader,🤖:bug

### Checked other resources

- [X] I added a very descriptive title to this issue.
- [X] I searched the LangChain documentation with the integrated search.
- [X] I used the GitHub search to find a similar question and didn't find it.
- [X] I am sure that this is a bug in LangChain rather than my code.
- [X] The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

### Example Code

``` python
doc = UnstructuredFileLoader(FILEPATH,encoding="utf-8",language='vi')
```
Test file
[2024_2_Công ty cổ phần HHP GLOBAL_BCDKT.csv](https://github.com/user-attachments/files/16617467/2024_2_Cong.ty.c.ph.n.HHP.GLOBAL_BCDKT.csv)


### Error Message and Stack Trace (if applicable)

```
UnicodeDecodeError                        Traceback (most recent call last)
Cell In[35], line 1
----> 1 custom_loader(filepath)

Cell In[34], line 12, in custom_loader(path)
     10 LCTT_TT_2 = x['detailed_report_data']['LCTT-TT_2']
     11 doc = UnstructuredFileLoader(BCDKT,encoding="utf-8",language='vi')
---> 12 d = doc.load()
     13 print(d)

File I:\env\langchain\Lib\site-packages\langchain_core\document_loaders\base.py:30, in BaseLoader.load(self)
     28 def load(self) -> List[Document]:
     29     """Load data into Document objects."""
---> 30     return list(self.lazy_load())

File I:\env\langchain\Lib\site-packages\langchain_community\document_loaders\unstructured.py:89, in UnstructuredBaseLoader.lazy_load(self)
     87 def lazy_load(self) -> Iterator[Document]:
     88     """Load file."""
---> 89     elements = self._get_elements()
     90     self._post_process_elements(elements)
     91     if self.mode == "elements":

File I:\env\langchain\Lib\site-packages\langchain_community\document_loaders\unstructured.py:181, in UnstructuredFileLoader._get_elements(self)
    179 if isinstance(self.file_path, Path):
    180     self.file_path = str(self.file_path)
--> 181 return partition(filename=self.file_path, **self.unstructured_kwargs)

File I:\env\langchain\Lib\site-packages\unstructured\partition\auto.py:529, in partition(filename, content_type, file, file_filename, url, include_page_breaks, strategy, encoding, paragraph_grouper, headers, skip_infer_table_types, ssl_verify, ocr_languages, languages, detect_language_per_element, pdf_infer_table_structure, extract_images_in_pdf, extract_image_block_types, extract_image_block_output_dir, extract_image_block_to_payload, xml_keep_tags, data_source_metadata, metadata_filename, request_timeout, hi_res_model_name, model_name, date_from_file_object, starting_page_number, **kwargs)
    527 elif filetype == FileType.CSV:
    528     _partition_csv = _get_partition_with_extras("csv")
--> 529     elements = _partition_csv(
    530         filename=filename,
    531         file=file,
    532         infer_table_structure=infer_table_structure,
    533         languages=languages,
    534         detect_language_per_element=detect_language_per_element,
    535         **kwargs,
    536     )
    537 elif filetype == FileType.TSV:
    538     _partition_tsv = _get_partition_with_extras("tsv")

File I:\env\langchain\Lib\site-packages\unstructured\documents\elements.py:593, in process_metadata.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
    591 @functools.wraps(func)
    592 def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> list[Element]:
--> 593     elements = func(*args, **kwargs)
    594     call_args = get_call_args_applying_defaults(func, *args, **kwargs)
    596     regex_metadata: dict["str", "str"] = call_args.get("regex_metadata", {})

File I:\env\langchain\Lib\site-packages\unstructured\file_utils\filetype.py:626, in add_filetype.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
    624 @functools.wraps(func)
    625 def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> List[Element]:
--> 626     elements = func(*args, **kwargs)
    627     params = get_call_args_applying_defaults(func, *args, **kwargs)
    628     include_metadata = params.get("include_metadata", True)

File I:\env\langchain\Lib\site-packages\unstructured\file_utils\filetype.py:582, in add_metadata.<locals>.wrapper(*args, **kwargs)
    580 @functools.wraps(func)
    581 def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> List[Element]:
--> 582     elements = func(*args, **kwargs)
    583     call_args = get_call_args_applying_defaults(func, *args, **kwargs)
    584     include_metadata = call_args.get("include_metadata", True)

File I:\env\langchain\Lib\site-packages\unstructured\chunking\dispatch.py:74, in add_chunking_strategy.<locals>.wrapper(*args, **kwargs)
     71 """The decorated function is replaced with this one."""
     73 # -- call the partitioning function to get the elements --
---> 74 elements = func(*args, **kwargs)
     76 # -- look for a chunking-strategy argument --
     77 call_args = get_call_args_applying_defaults(func, *args, **kwargs)

File I:\env\langchain\Lib\site-packages\unstructured\partition\csv.py:80, in partition_csv(filename, file, metadata_filename, metadata_last_modified, include_header, include_metadata, infer_table_structure, languages, date_from_file_object, **kwargs)
     77 header = 0 if include_header else None
     79 if filename:
---> 80     delimiter = get_delimiter(file_path=filename)
     81     table = pd.read_csv(filename, header=header, sep=delimiter)
     82     last_modification_date = get_last_modified_date(filename)

File I:\env\langchain\Lib\site-packages\unstructured\partition\csv.py:129, in get_delimiter(file_path, file)
    127 elif file_path is not None:
    128     with open(file_path) as f:
--> 129         data = "\n".join(f.readlines(num_bytes))
    130 else:
    131     raise ValueError("either `file_path` or `file` argument must be provided")

File I:\env\langchain\Lib\encodings\cp1252.py:23, in IncrementalDecoder.decode(self, input, final)
     22 def decode(self, input, final=False):
---> 23     return codecs.charmap_decode(input,self.errors,decoding_table)[0]

UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 99: character maps to <undefined>
```

### Description

I am trying to use UnstructuredFileLoader to load an UTF-8 CSV file in Vietnamese but it seems to be encountering some encoding issue no matter the arguments that I passed to it.

### System Info

System Information
------------------
> OS:  Windows
> OS Version:  10.0.26257
> Python Version:  3.12.5 | packaged by conda-forge | (main, Aug  8 2024, 18:24:51) [MSC v.1940 64 bit (AMD64)]

Package Information
-------------------
> langchain_core: 0.2.25
> langchain: 0.2.13
> langchain_community: 0.2.7
> langsmith: 0.1.99
> langchain_anthropic: 0.1.19
> langchain_cli: 0.0.25
> langchain_google_vertexai: 1.0.6
> langchain_openai: 0.1.14
> langchain_text_splitters: 0.2.2
> langchain_unstructured: 0.1.1
> langgraph: 0.1.5
> langserve: 0.2.2

Other Dependencies
------------------
> aiohttp: 3.10.3
> anthropic: 0.31.2
> anthropic[vertexai]: Installed. No version info available.
> async-timeout: 4.0.3
> dataclasses-json: 0.6.7
> defusedxml: 0.7.1
> fastapi: 0.110.3
> gitpython: 3.1.43
> google-cloud-aiplatform: 1.58.0
> google-cloud-storage: 2.17.0
> httpx: 0.27.0
> jsonpatch: 1.33
> langserve[all]: Installed. No version info available.
> libcst: 1.4.0
> numpy: 1.26.4
> openai: 1.35.10
> orjson: 3.10.7
> packaging: 24.1
> pydantic: 2.8.2
> pyproject-toml: 0.0.10
> PyYAML: 6.0.2
> requests: 2.32.3
> SQLAlchemy: 2.0.32
> sse-starlette: 1.8.2
> tenacity: 8.5.0
> tiktoken: 0.7.0
> tomlkit: 0.12.5
> typer[all]: Installed. No version info available.
> unstructured-client: 0.24.1
> unstructured[all-docs]: Installed. No version info available.
> uvicorn: 0.23.2