# File$read

### Fil&#x65;**$**<mark style="color:purple;">**read**</mark>**(***\*, as\_text=False, start\_byte=0, end\_byte=NULL***)** → bytes | str

Reads the file contents into memory, either as raw bytes or as a string.

### **Parameters:**

**`as_text` :&#x20;*****bool, default False***\
Whether to read the file contents as a string. By default, the raw bytes of the file will be returned.

**`start_byte` :&#x20;*****int, default 0***\
The offset byte at which to start reading the file. Allows for reading part of a file. If not specified, the file will be read from the start.

**`end_byte` :&#x20;*****int, default NULL***\
The byte at which to stop reading the file, inclusive. Allows for reading part of a file. If not specified, the file will be read to the end.

### **Returns:**

**bytes | str**

### Examples

```r
t <- redivis$table("demo.example_data_files:yz1s:v1_3.example_file_types:4c10")
f <- t$file("pandas_core.py")

file_contents <- f$read(as_text=TRUE)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.redivis.com/api/client-libraries/redivis-r/reference/file/fileusdread.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
