# Notebook Issues - Read CSV

**URL:** https://forums.losant.com/t/notebook-issues-read-csv/2557
**Category:** Help
**Tags:** notebooks
**Created:** [January 21, 2020, 7:07pm UTC](https://forums.losant.com/t/notebook-issues-read-csv/2557 "2020-01-21T19:07:07Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ChrisGM](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@ChrisGM](https://forums.losant.com/u/ChrisGM)
#### Post date: [January 21, 2020, 7:07pm UTC](https://forums.losant.com/t/notebook-issues-read-csv/2557/1 "2020-01-21T19:07:07Z")

</div>

Hi All,

I’m struggling to get anything out of my notebooks. I’ve tried lots of different variations and examples from the forums but can’t seem to find one which works for me.

I have setup a simple input. 60 minutes of data into data.csv

## I have setup a simple Notebook file. Code is:

import os  
import pandas as pd

input\_dir = os.path.join(os.environ[‘INPUT\_DIR’])

dataset = pd.read\_csv(input\_dir, ‘data.csv’)

–

My notebook debug is:

–

## [NbConvertApp] Converting notebook /tmp/input.ipynb to notebook [NbConvertApp] Executing notebook with kernel: python3 [NbConvertApp] ERROR | Error while converting ‘/tmp/input.ipynb’ Traceback (most recent call last): File “/opt/conda/lib/python3.7/site-packages/nbconvert/nbconvertapp.py”, line 407, in export\_single\_notebook output, resources = self.exporter.from\_filename(notebook\_filename, resources=resources) File “/opt/conda/lib/python3.7/site-packages/nbconvert/exporters/exporter.py”, line 178, in from\_filename return self.from\_file(f, resources=resources, \*\*kw) File “/opt/conda/lib/python3.7/site-packages/nbconvert/exporters/exporter.py”, line 196, in from\_file return self.from\_notebook\_node(nbformat.read(file\_stream, as\_version=4), resources=resources, \*\*kw) File “/opt/conda/lib/python3.7/site-packages/nbconvert/exporters/notebook.py”, line 32, in from\_notebook\_node nb\_copy, resources = super(NotebookExporter, self).from\_notebook\_node(nb, resources, \*\*kw) File “/opt/conda/lib/python3.7/site-packages/nbconvert/exporters/exporter.py”, line 138, in from\_notebook\_node nb\_copy, resources = self.\_preprocess(nb\_copy, resources) File “/opt/conda/lib/python3.7/site-packages/nbconvert/exporters/exporter.py”, line 315, in \_preprocess nbc, resc = preprocessor(nbc, resc) File “/opt/conda/lib/python3.7/site-packages/nbconvert/preprocessors/base.py”, line 47, in **call** return self.preprocess(nb, resources) File “/opt/conda/lib/python3.7/site-packages/nbconvert/preprocessors/execute.py”, line 354, in preprocess nb, resources = super(ExecutePreprocessor, self).preprocess(nb, resources) File “/opt/conda/lib/python3.7/site-packages/nbconvert/preprocessors/base.py”, line 69, in preprocess nb.cells[index], resources = self.preprocess\_cell(cell, resources, index) File “/opt/conda/lib/python3.7/site-packages/nbconvert/preprocessors/execute.py”, line 378, in preprocess\_cell raise CellExecutionError.from\_cell\_and\_msg(cell, out) nbconvert.preprocessors.execute.CellExecutionError: An error occurred while executing the following cell:

import os  
import pandas as pd

input\_dir = os.path.join(os.environ[‘INPUT\_DIR’])

## dataset = pd.read\_csv(input\_dir, ‘data.csv’)

* * *

IsADirectoryError Traceback (most recent call last)  
 in   
4 input\_dir = os.path.join(os.environ[‘INPUT\_DIR’])  
5  
----\> 6 dataset = pd.read\_csv(input\_dir, ‘data.csv’)

/opt/conda/lib/python3.7/site-packages/pandas/io/parsers.py in parser\_f(filepath\_or\_buffer, sep, delimiter, header, names, index\_col, usecols, squeeze, prefix, mangle\_dupe\_cols, dtype, engine, converters, true\_values, false\_values, skipinitialspace, skiprows, skipfooter, nrows, na\_values, keep\_default\_na, na\_filter, verbose, skip\_blank\_lines, parse\_dates, infer\_datetime\_format, keep\_date\_col, date\_parser, dayfirst, cache\_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, dialect, error\_bad\_lines, warn\_bad\_lines, delim\_whitespace, low\_memory, memory\_map, float\_precision)  
683 )  
684  
–\> 685 return \_read(filepath\_or\_buffer, kwds)  
686  
687 parser\_f. **name** = name

/opt/conda/lib/python3.7/site-packages/pandas/io/parsers.py in \_read(filepath\_or\_buffer, kwds)  
455  
456 # Create the parser.  
–\> 457 parser = TextFileReader(fp\_or\_buf, \*\*kwds)  
458  
459 if chunksize or iterator:

/opt/conda/lib/python3.7/site-packages/pandas/io/parsers.py in **init** (self, f, engine, \*\*kwds)  
893 self.options[“has\_index\_names”] = kwds[“has\_index\_names”]  
894  
–\> 895 self.\_make\_engine(self.engine)  
896  
897 def close(self):

/opt/conda/lib/python3.7/site-packages/pandas/io/parsers.py in \_make\_engine(self, engine)  
1145 ’ “python-fwf”)’.format(engine=engine)  
1146 )  
-\> 1147 self.\_engine = klass(self.f, \*\*self.options)  
1148  
1149 def \_failover\_to\_python(self):

/opt/conda/lib/python3.7/site-packages/pandas/io/parsers.py in **init** (self, f, \*\*kwds)  
2280 encoding=self.encoding,  
2281 compression=self.compression,  
-\> 2282 memory\_map=self.memory\_map,  
2283 )  
2284 self.handles.extend(handles)

/opt/conda/lib/python3.7/site-packages/pandas/io/common.py in \_get\_handle(path\_or\_buf, mode, encoding, compression, memory\_map, is\_text)  
398 elif is\_text:  
399 # No explicit encoding  
–\> 400 f = open(path\_or\_buf, mode, errors=“replace”, newline="")  
401 else:  
402 # Binary mode

IsADirectoryError: [Errno 21] Is a directory: ‘/tmp/input/’  
IsADirectoryError: [Errno 21] Is a directory: ‘/tmp/input/’

Jupyter exited with status code: 1

–

Any advice would be appreciated.

I have managed to get some other notebooks working on my local machine. However porting to Losant is my issue.

Many thanks,  
Chris

---

<div class="post-metadata">

### Author: ![JuliaKempf](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/juliakempf/32/2446_2.png) [@JuliaKempf](https://forums.losant.com/u/JuliaKempf)
#### Post date: [January 21, 2020, 8:28pm UTC](https://forums.losant.com/t/notebook-issues-read-csv/2557/3 "2020-01-21T20:28:11Z")

</div>

Hi @ChrisGM,

We here at the Losant Forums are happy to help with Losant Notebook problems surrounding accessing data and performing analysis. Our expertise lies in the Losant Platform, so we recommend checking out the [Jupyter Blog](https://blog.jupyter.org/), the [Jupyter Live Chat](https://gitter.im/jupyter/jupyter), or posting on the [Jupyter Discourse Forum](https://discourse.jupyter.org/) for challenging problems within the Jupyter Notebook and help writing Notebook Code. In this case, it looks as though this snippet will cause some issues:

```auto
input_dir = os.path.join(os.environ[‘INPUT_DIR’])
dataset = pd.read_csv(input_dir, ‘data.csv’)

```

In this first line, you are not joining any values, which is likely resulting in this error; I will update the documentation to fix this snippet. I would recommend rewriting this to:

```auto
dataset = pd.read_csv(os.path.join(os.environ['INPUT_DIR'], 'data.csv'))

```

Please let me know if this does not provide a resolution,  
Julia
