admin管理员组文章数量:1405192
I would like to try to work the dataset in Jupyter Notebook from the iPhone Carnets App, but I can’t search the correct path. If someone can help me.
The dataset I download from Kaggle. Are free files that I push into a folder. I try this code:
import pandas as pd
aguacates = pd.read_excel("En mi iPhone ▸ video141_python_pildorasInfor ▸ Aguacate producción.xlsx")
print(aguacates)
And also this other:
import pandas as pd
aguacates = pd.read_excel("En mi iPhone \\video141_python_pildorasInfor\\Aguacate producción.xlsx")
(aguacates)
The error is:
`FileNotFoundError Traceback (most recent call last)
Cell In[2], line 3
1 import pandas as pd
----> 3 aguacates = pd.read_excel("En mi iPhone\\video141_python_pildorasInfor\\Aguacate producción.xlsx")
4 print(aguacates)
File /private/var/containers/Bundle/Application/D169301A-0DB7-4982-8FE3-9C6D0E0C17D8/Carnets.app/Library/lib/python3.11/site-packages/pandas/io/excel/_base.py:478, in read_excel(io, sheet_name, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, parse_dates, date_parser, date_format, thousands, decimal, comment, skipfooter, storage_options, dtype_backend)
476 if not isinstance(io, ExcelFile):
477 should_close = True
--> 478 io = ExcelFile(io, storage_options=storage_options, engine=engine)
479 elif engine and engine != io.engine:
480 raise ValueError(
481 "Engine should not be specified when passing "
482 "an ExcelFile - ExcelFile already has the engine set"
483 )
File /private/var/containers/Bundle/Application/D169301A-0DB7-4982-8FE3-9C6D0E0C17D8/Carnets.app/Library/lib/python3.11/site-packages/pandas/io/excel/_base.py:1496, in ExcelFile.__init__(self, path_or_buffer, engine, storage_options)
1494 ext = "xls"
1495 else:
-> 1496 ext = inspect_excel_format(
1497 content_or_path=path_or_buffer, storage_options=storage_options
1498 )
1499 if ext is None:
1500 raise ValueError(
1501 "Excel file format cannot be determined, you must specify "
1502 "an engine manually."
1503 )
File /private/var/containers/Bundle/Application/D169301A-0DB7-4982-8FE3-9C6D0E0C17D8/Carnets.app/Library/lib/python3.11/site-packages/pandas/io/excel/_base.py:1371, in inspect_excel_format(content_or_path, storage_options)
1368 if isinstance(content_or_path, bytes):
1369 content_or_path = BytesIO(content_or_path)
-> 1371 with get_handle(
1372 content_or_path, "rb", storage_options=storage_options, is_text=False
1373 ) as handle:
1374 stream = handle.handle
1375 stream.seek(0)
File /private/var/containers/Bundle/Application/D169301A-0DB7-4982-8FE3-9C6D0E0C17D8/Carnets.app/Library/lib/python3.11/site-packages/pandas/io/common.py:868, in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)
859 handle = open(
860 handle,
861 ioargs.mode,
(...)
864 newline="",
865 )
866 else:
867 # Binary mode
--> 868 handle = open(handle, ioargs.mode)
869 handles.append(handle)
871 # Convert BytesIO or file objects passed with an encoding
FileNotFoundError: [Errno 2] No such file or directory: '\u2068\u2068En mi iPhone\u2069\\\u2068video141_python_pildorasInfor\u2069\\Aguacate producción.xlsx'`
I would like to try to work the dataset in Jupyter Notebook from the iPhone Carnets App, but I can’t search the correct path. If someone can help me.
The dataset I download from Kaggle. Are free files that I push into a folder. I try this code:
import pandas as pd
aguacates = pd.read_excel("En mi iPhone ▸ video141_python_pildorasInfor ▸ Aguacate producción.xlsx")
print(aguacates)
And also this other:
import pandas as pd
aguacates = pd.read_excel("En mi iPhone \\video141_python_pildorasInfor\\Aguacate producción.xlsx")
(aguacates)
The error is:
`FileNotFoundError Traceback (most recent call last)
Cell In[2], line 3
1 import pandas as pd
----> 3 aguacates = pd.read_excel("En mi iPhone\\video141_python_pildorasInfor\\Aguacate producción.xlsx")
4 print(aguacates)
File /private/var/containers/Bundle/Application/D169301A-0DB7-4982-8FE3-9C6D0E0C17D8/Carnets.app/Library/lib/python3.11/site-packages/pandas/io/excel/_base.py:478, in read_excel(io, sheet_name, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, parse_dates, date_parser, date_format, thousands, decimal, comment, skipfooter, storage_options, dtype_backend)
476 if not isinstance(io, ExcelFile):
477 should_close = True
--> 478 io = ExcelFile(io, storage_options=storage_options, engine=engine)
479 elif engine and engine != io.engine:
480 raise ValueError(
481 "Engine should not be specified when passing "
482 "an ExcelFile - ExcelFile already has the engine set"
483 )
File /private/var/containers/Bundle/Application/D169301A-0DB7-4982-8FE3-9C6D0E0C17D8/Carnets.app/Library/lib/python3.11/site-packages/pandas/io/excel/_base.py:1496, in ExcelFile.__init__(self, path_or_buffer, engine, storage_options)
1494 ext = "xls"
1495 else:
-> 1496 ext = inspect_excel_format(
1497 content_or_path=path_or_buffer, storage_options=storage_options
1498 )
1499 if ext is None:
1500 raise ValueError(
1501 "Excel file format cannot be determined, you must specify "
1502 "an engine manually."
1503 )
File /private/var/containers/Bundle/Application/D169301A-0DB7-4982-8FE3-9C6D0E0C17D8/Carnets.app/Library/lib/python3.11/site-packages/pandas/io/excel/_base.py:1371, in inspect_excel_format(content_or_path, storage_options)
1368 if isinstance(content_or_path, bytes):
1369 content_or_path = BytesIO(content_or_path)
-> 1371 with get_handle(
1372 content_or_path, "rb", storage_options=storage_options, is_text=False
1373 ) as handle:
1374 stream = handle.handle
1375 stream.seek(0)
File /private/var/containers/Bundle/Application/D169301A-0DB7-4982-8FE3-9C6D0E0C17D8/Carnets.app/Library/lib/python3.11/site-packages/pandas/io/common.py:868, in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)
859 handle = open(
860 handle,
861 ioargs.mode,
(...)
864 newline="",
865 )
866 else:
867 # Binary mode
--> 868 handle = open(handle, ioargs.mode)
869 handles.append(handle)
871 # Convert BytesIO or file objects passed with an encoding
FileNotFoundError: [Errno 2] No such file or directory: '\u2068\u2068En mi iPhone\u2069\\\u2068video141_python_pildorasInfor\u2069\\Aguacate producción.xlsx'`
Share
Improve this question
asked Mar 9 at 3:23
Samusdr17Samusdr17
1
5
|
1 Answer
Reset to default 0Due to iOS peculiarities, a notebook in Carnets can not open files at arbitrary locations (using an absolute path). It is easier to have the data file and the notebook in the same folder, and use a relative path:
aguacates = pd.read_excel("Aguacate producción.xlsx")
I'm the author of Carnets.
本文标签: pythonHow to import xlsx in Jupyter Notebook from iPhone Carnets AppStack Overflow
版权声明:本文标题:python - How to import .xlsx in Jupyter Notebook from iPhone Carnets App? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744879390a2630114.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
os.listdir()
to check files in current working folder, andos.listdir("..")
to check parent folder, andos.listdir("../..")
another level. This way you could check structure of folders - and see if folders has names as you expect. You may also start from root folder -os.listdir("/")
. – furas Commented Mar 9 at 8:33os.getcwd()
) but maybe you should create/full/path/to/file
or add..
,../..
, etc. in your path if you need relative path. – furas Commented Mar 9 at 8:35pd.read_excel("https://....xlsx")
so you may try to load it directly from Kaggle. But first check if this file can be downloaded when you are not logfed in on Kaggle because some information needs to be logged in. – furas Commented Mar 9 at 8:37/private/../.../
with/
- so you can also use/
instead of\\
– furas Commented Mar 9 at 8:39