> For the complete documentation index, see [llms.txt](https://fennaf.gitbook.io/dataprocessing/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fennaf.gitbook.io/dataprocessing/load-data-1/csv.md).

# CSV

comma-separated files

## Reading csv

```python
pd.read_csv() #read a csv file into pandas Dataframe
df.to_csv #write a pandas DataFrame into a csv file
```

The most commonly used read function is `read_csv`.There are a number of functions that convert text data into a DataFrame. Most of these functions have optional arguments that handle column names, missing values, datetime parsing, skipping rows, dealing with thousand separated comma's, and so on.&#x20;

```python
import pandas as pd
df = pd.read_csv('data/mydata.csv', sep=';')
df.head()
```

For instance, if you want to read a small number of rows you can specify that with `nrows`

```python
df = pd.read_csv('data/mydata.csv', sep=';', nrows=10)
```

Using the DataFrames `to_csv` method, we can write the data out to a comma-separated file:

```python
df.to_csv('output/output.csv')
```
