question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

read_csv() not working

See original GitHub issue

Hi,

url = "https://raw.githubusercontent.com/r0f1/sample_datasets/master/bank-additional-full.csv"

import pandas as pd
pd.read_csv(url, sep=";")

import dask.dataframe as dd
df = dd.read_csv(url, sep=";")

The first command works, the second does not. I get the following error message. Why it that?

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-28-18ee5ee6fd2a> in <module>
----> 1 df = dd.read_csv("https://raw.githubusercontent.com/r0f1/sample_datasets/master/bank-additional-full.csv", sep=";")

/opt/conda/lib/python3.7/site-packages/dask/dataframe/io/csv.py in read(urlpath, blocksize, collection, lineterminator, compression, sample, enforce, assume_missing, storage_options, include_path_column, **kwargs)
    486                            storage_options=storage_options,
    487                            include_path_column=include_path_column,
--> 488                            **kwargs)
    489     read.__doc__ = READ_DOC_TEMPLATE.format(reader=reader_name,
    490                                             file_type=file_type)

/opt/conda/lib/python3.7/site-packages/dask/dataframe/io/csv.py in read_pandas(reader, urlpath, blocksize, collection, lineterminator, compression, sample, enforce, assume_missing, storage_options, include_path_column, **kwargs)
    341                        compression=compression,
    342                        include_path=include_path_column,
--> 343                        **(storage_options or {}))
    344 
    345     if include_path_column:

/opt/conda/lib/python3.7/site-packages/dask/bytes/core.py in read_bytes(urlpath, delimiter, not_zero, blocksize, sample, compression, include_path, **kwargs)
    126         with OpenFile(fs, paths[0], compression=compression) as f:
    127             nbytes = 10000 if sample is True else sample
--> 128             sample = read_block(f, 0, nbytes, delimiter)
    129     if include_path:
    130         return sample, out, paths

/opt/conda/lib/python3.7/site-packages/dask/bytes/utils.py in read_block(f, offset, length, delimiter)
    236         f.seek(offset)
    237 
--> 238     return f.read(length)
    239 
    240 

/opt/conda/lib/python3.7/site-packages/dask/bytes/http.py in read(self, length)
    183             # EOF (python files don't error, just return no data)
    184             return b''
--> 185         self. _fetch(self.loc, end)
    186         data = self.cache[self.loc - self.start:end - self.start]
    187         self.loc = end

/opt/conda/lib/python3.7/site-packages/dask/bytes/http.py in _fetch(self, start, end)
    203                 new = self._fetch_range(start, self.start)
    204                 self.start = start
--> 205                 self.cache = new + self.cache
    206         elif end > self.end:
    207             if self.end > self.size:

TypeError: can't concat NoneType to bytes

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
martindurantcommented, Apr 8, 2019

Sorry for the problem. A quick-fix has been made, so you can run from master or wait for a release (they come along pretty fast).

0reactions
argenisleoncommented, Jan 27, 2020

Master works. I use pip install --upgrade --force-reinstall git+https://github.com/intake/filesystem_spec.git Thanks @martindurant

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pandas read_csv() does not work for me - Stack Overflow
If I try to read the data with print pd. read_csv('DAX. csv'), I get this: [6246 rows x 1 columns].
Read more >
Error - unable to read the csv file in pandas
Seems that pandas is not able to find the file, check if the file 'data.csv' is in same directory as the python script...
Read more >
read_csv - could not find function - RStudio Community
I am trying to use the read_csv file to read an csv file but getting the error below: could not find function "read_csv"....
Read more >
Python read_csv problem | Data Science and Machine Learning
I'm not able to open files in Windows 10… import pandas as pd df = pd.read_csv('avocado.csv') I got the FileNotFoundError: File b'avocado.csv' does...
Read more >
Error-free import of CSV files using Pandas DataFrame
Reading and importing the CSV file is not so simple as one may surmise. Here are some tips which must be kept in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found