Jupyter 笔记本无法读取 csv 文件
Jupyter notebook unable to read csv files
我想导入这个 CSV 文件
tweets = pd.read_csv('/Users/yoshithKotla/Desktop/canal/Music/wmsrry/wmsrry_only')
print(tweets)
但它显示了这样的错误,文件位于与提到的完全相同的位置,我无法导入 CSV 文件,我在桌面上尝试了一些其他 CSV 文件,错误仍然显示。
没有重复的文件,也没有任何其他格式不同的同名文件。我想不通
FileNotFoundError Traceback (most recent call last)
<ipython-input-10-ba5ff0134d9f> in <module>
----> 1 tweets = pd.read_csv('/Users/yoshithKotla/Desktop/canal/Music/wmsrry/wmsrry_only')
2
3 print(tweets)
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/io/parsers.py in read_csv(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, storage_options)
608 kwds.update(kwds_defaults)
609
--> 610 return _read(filepath_or_buffer, kwds)
611
612
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds)
460
461 # Create the parser.
--> 462 parser = TextFileReader(filepath_or_buffer, **kwds)
463
464 if chunksize or iterator:
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/io/parsers.py in __init__(self, f, engine, **kwds)
817 self.options["has_index_names"] = kwds["has_index_names"]
818
--> 819 self._engine = self._make_engine(self.engine)
820
821 def close(self):
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/io/parsers.py in _make_engine(self, engine)
1048 )
1049 # error: Too many arguments for "ParserBase"
-> 1050 return mapping[engine](self.f, **self.options) # type: ignore[call-arg]
1051
1052 def _failover_to_python(self):
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/io/parsers.py in __init__(self, src, **kwds)
1865
1866 # open handles
-> 1867 self._open_handles(src, kwds)
1868 assert self.handles is not None
1869 for key in ("storage_options", "encoding", "memory_map", "compression"):
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/io/parsers.py in _open_handles(self, src, kwds)
1360 Let the readers open IOHanldes after they are done with their potential raises.
1361 """
-> 1362 self.handles = get_handle(
1363 src,
1364 "r",
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/io/common.py in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)
640 errors = "replace"
641 # Encoding
--> 642 handle = open(
643 handle,
644 ioargs.mode,
FileNotFoundError: [Errno 2] No such file or directory: '/Users/yoshithKotla/Desktop/canal/Music/wmsrry/wmsrry_only'
能否在地址末尾加上“.csv”试试。
示例:
tweets = pd.read_csv('/Users/yoshithKotla/Desktop/canal/Music/wmsrry/wmsrry_only.csv')
假设该文件确实是一个 CSV 文件,并且您 Mac 隐藏了扩展名,请尝试将文件的扩展名 .csv
恢复。类似于 wmsrry_only.csv
。或完整路径 /Users/yoshithKotla/Desktop/canal/Music/wmsrry/wmsrry_only.csv
现在如果你能用Number app打开它,它也可能是一个Excel文件。
如果您想确定,请打开终端应用程序并进入该目录,然后 运行 ls -la
查看带有扩展名的文件和 运行 file <file>
将 <file>
替换为您从上一个命令中找到的文件名和扩展名。
我想导入这个 CSV 文件
tweets = pd.read_csv('/Users/yoshithKotla/Desktop/canal/Music/wmsrry/wmsrry_only')
print(tweets)
但它显示了这样的错误,文件位于与提到的完全相同的位置,我无法导入 CSV 文件,我在桌面上尝试了一些其他 CSV 文件,错误仍然显示。 没有重复的文件,也没有任何其他格式不同的同名文件。我想不通
FileNotFoundError Traceback (most recent call last)
<ipython-input-10-ba5ff0134d9f> in <module>
----> 1 tweets = pd.read_csv('/Users/yoshithKotla/Desktop/canal/Music/wmsrry/wmsrry_only')
2
3 print(tweets)
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/io/parsers.py in read_csv(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, storage_options)
608 kwds.update(kwds_defaults)
609
--> 610 return _read(filepath_or_buffer, kwds)
611
612
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds)
460
461 # Create the parser.
--> 462 parser = TextFileReader(filepath_or_buffer, **kwds)
463
464 if chunksize or iterator:
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/io/parsers.py in __init__(self, f, engine, **kwds)
817 self.options["has_index_names"] = kwds["has_index_names"]
818
--> 819 self._engine = self._make_engine(self.engine)
820
821 def close(self):
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/io/parsers.py in _make_engine(self, engine)
1048 )
1049 # error: Too many arguments for "ParserBase"
-> 1050 return mapping[engine](self.f, **self.options) # type: ignore[call-arg]
1051
1052 def _failover_to_python(self):
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/io/parsers.py in __init__(self, src, **kwds)
1865
1866 # open handles
-> 1867 self._open_handles(src, kwds)
1868 assert self.handles is not None
1869 for key in ("storage_options", "encoding", "memory_map", "compression"):
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/io/parsers.py in _open_handles(self, src, kwds)
1360 Let the readers open IOHanldes after they are done with their potential raises.
1361 """
-> 1362 self.handles = get_handle(
1363 src,
1364 "r",
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/io/common.py in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)
640 errors = "replace"
641 # Encoding
--> 642 handle = open(
643 handle,
644 ioargs.mode,
FileNotFoundError: [Errno 2] No such file or directory: '/Users/yoshithKotla/Desktop/canal/Music/wmsrry/wmsrry_only'
能否在地址末尾加上“.csv”试试。 示例:
tweets = pd.read_csv('/Users/yoshithKotla/Desktop/canal/Music/wmsrry/wmsrry_only.csv')
假设该文件确实是一个 CSV 文件,并且您 Mac 隐藏了扩展名,请尝试将文件的扩展名 .csv
恢复。类似于 wmsrry_only.csv
。或完整路径 /Users/yoshithKotla/Desktop/canal/Music/wmsrry/wmsrry_only.csv
现在如果你能用Number app打开它,它也可能是一个Excel文件。
如果您想确定,请打开终端应用程序并进入该目录,然后 运行 ls -la
查看带有扩展名的文件和 运行 file <file>
将 <file>
替换为您从上一个命令中找到的文件名和扩展名。