# Dica 31 - Importando CSV com Pandas

[![](/files/-MfuAP1e7W4erW9hf6Ic)](https://youtu.be/SaCCzTRSuYg)

<https://towardsdatascience.com/pandas-vs-dask-vs-datatable-a-performance-comparison-for-processing-csv-files-3b0e0e98215e>

```
pip install pandas
pip freeze | grep pandas >> requirements.txt

python manage.py shell_plus --notebook
```

```python
import pandas as pd

df = pd.read_csv('/tmp/products.csv')

df

df.max()

df.min()

Product.objects.all().delete()

def save_data(data):
    '''
    Salva os dados no banco.
    '''
    aux = []
    for item in data:
        title = item.get('title')
        price = item.get('price')
        obj = Product(
            title=title,
            price=price,
        )
        aux.append(obj)

    Product.objects.bulk_create(aux)

data = []

for row in df.itertuples():
    _dict = dict(title=row.title, price=row.price)
    data.append(_dict)

data

save_data(data)

Product.objects.all().count()
```


---

# 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://www.dicas-de-django.com.br/097-31-import-csv-pandas.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.
