# Need help importing a single-channel EEG file (CSV)

**URL:** <https://mne.discourse.group/t/need-help-importing-a-single-channel-eeg-file-csv/3710>\
**Category:** Support & Discussions\
**Tags:** data-import\
**Created:** [September 17, 2021, 12:20am UTC](https://mne.discourse.group/t/need-help-importing-a-single-channel-eeg-file-csv/3710 "2021-09-17T00:20:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![enthusiastprogrammer](https://avatars.discourse-cdn.com/v4/letter/e/eb9ed0/32.png) [@enthusiastprogrammer](https://mne.discourse.group/u/enthusiastprogrammer)\
**Post date:** [September 17, 2021, 12:20am UTC](https://mne.discourse.group/t/need-help-importing-a-single-channel-eeg-file-csv/3710/1 "2021-09-17T00:20:17Z")

</div>

Hi, I am new to the forums and am looking for help importing a single-channel CSV file. I am attaching my code below for reference.

```python
import pandas as pd
import json
import numpy as np
import os
import csv
import mne
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
from bs4 import BeautifulSoup
from urllib.request import urlopen
path="/Users/enthusiastprogrammer/Desktop/Datasets"
os.chdir(path)

data = np.genfromtxt('mydata.csv',delimiter=',')
ch_names = ['CH 1']
sfreq = 300 #Hz
#info = mne.create_info(ch_names=["2"], sfreq=300)
info = mne.create_info(ch_names=ch_names, sfreq=sfreq)
mne.io.RawArray(data, info)

```

And here’s my error:

```python
ValueError Traceback (most recent call last)
<ipython-input-4-cd2014e5f50c> in <module>
      9 #info = mne.create_info(ch_names=["2"], sfreq=300)
     10 info = mne.create_info(ch_names=ch_names, sfreq=sfreq)
---> 11 mne.io.RawArray(data, info)

<decorator-gen-192> in __init__ (self, data, info, first_samp, copy, verbose)

~/opt/anaconda3/lib/python3.8/site-packages/mne/io/array/array.py in __init__ (self, data, info, first_samp, copy, verbose)
     60 data = np.asanyarray(orig_data, dtype=dtype)
     61 if data.ndim != 2:
---> 62 raise ValueError('Data must be a 2D array of shape (n_channels, '
     63 'n_samples), got shape %s' % (data.shape,))
     64 if len(data) != len(info['ch_names']):

ValueError: Data must be a 2D array of shape (n_channels, n_samples), got shape (9595,)

```

Would appreciate if any of you could help ASAP - I scoured the internet and couldn’t find an answer. Thanks so much!

- MNE-Python version: 0.23.4
- operating system: MacOS Big Sur Version 11.6

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [September 17, 2021, 6:23am UTC](https://mne.discourse.group/t/need-help-importing-a-single-channel-eeg-file-csv/3710/2 "2021-09-17T06:23:25Z")

</div>

Hello @enthusiastprogrammer and welcome to the forum!

As the error message suggests, the shape of your data array is one-dimensional, but it must be 2-dimensional. What you can do to correct this is:

```python
data = np.atleast_2d(data)

```

Then it should work. Be sure to check the resulting dimensions of the array via `data.shape`; it should be `(1, 9595)` (1 channel, 9595 time points).

Best wishes,  
Richard

PS: Please format code snippets as such to improve readability. To do this, when editing a posting simply select the code blocks and click on the “Preformatted text” button in the toolbar. I’ve already edited your posting accordingly. Thanks you!
