| [ Web Proxy ] |
| Viewing: https://arrow.apache.org/docs/python/generated/../api/../api/../generated/pyarrow.csv.read_csv.html | [Back] [Original] |
Section Navigation
Read a Table from a stream of CSV data.
str, path or file-like objectThe location of CSV data. If a string or path, and if it ends with a recognized compressed file extension (e.g. .gz or .bz2), the data is automatically decompressed when reading.
pyarrow.csv.ReadOptions, optionalOptions for the CSV reader (see pyarrow.csv.ReadOptions constructor for defaults)
pyarrow.csv.ParseOptions, optionalOptions for the CSV parser (see pyarrow.csv.ParseOptions constructor for defaults)
pyarrow.csv.ConvertOptions, optionalOptions for converting CSV data (see pyarrow.csv.ConvertOptions constructor for defaults)
MemoryPool, optionalPool to allocate Table memory from
pyarrow.TableContents of the CSV file as a in-memory table.
Examples
Defining an example file from bytes object:
>>> import io
>>> s = (
... "animals,n_legs,entry\n"
... "Flamingo,2,2022-03-01\n"
... "Horse,4,2022-03-02\n"
... "Brittle stars,5,2022-03-03\n"
... "Centipede,100,2022-03-04"
... )
>>> print(s)
animals,n_legs,entry
Flamingo,2,2022-03-01
Horse,4,2022-03-02
Brittle stars,5,2022-03-03
Centipede,100,2022-03-04
>>> source = io.BytesIO(s.encode())
Reading from the file
>>> from pyarrow import csv
>>> csv.read_csv(source)
pyarrow.Table
animals: string
n_legs: int64
entry: date32[day]
----
animals: [["Flamingo","Horse","Brittle stars","Centipede"]]
n_legs: [[2,4,5,100]]
entry: [[2022-03-01,2022-03-02,2022-03-03,2022-03-04]]
Copyright 2016-2026 Apache Software Foundation.
Apache Arrow, Arrow, Apache, the Apache logo, and the Apache Arrow project logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries.
Created using Sphinx 9.1.0.
Built with the PyData Sphinx Theme 0.20.0.
| Web Proxy Viewer | New URL | Original Page |