Hi guys,
Quick question, does any1 know why i get returned
Error:
C:\ProgramData\Anaconda3\python.exe: can't find '__main__' module in \test.xlsx
when i wanna run basic code:
import pandas as pd
df = pd.read_excel(r'C:\Desktop\New Foldert\test.xlsx')#, sheet_name='blabla')
print(df)
#EDIT
<facepalm>
I was using wrong dir >.<
I tried your code on Linux, but made a few modifications first
modifications:
- imported os and set cwd to the script directory
- placed an xlsx file in the script directory This file just happened to be lying around (Airports.xlsx)
- Opened file directly
All worked fine:
import pandas as pd
import os
os.chdir(os.path.abspath(os.path.dirname(__file__)))
df = pd.read_excel(r'Airports.xlsx')#, sheet_name='blabla')
print(df)
results when run:
Output:
OBJECTID FAA_ID TYPE_ NAME ... OWN_TYPE OWNER MANAGER USE_TYPE
0 1 ILG Airport New Castle Airport ... public New Castle County Delaware River and Bay Authority (DRBA) public
1 2 EVY Airport Summit Aviation ... private Greenwich Aerogroup Greenwich Aerogroup public
2 3 38N Airport Smyrna Airport ... private Barbara Jones Robert Jones public
3 4 33N Airport Delaware Airpark ... public Delaware Department of Transportation (DelDOT) Delaware River and Bay Authority (DRBA) public
4 5 0N4 Airport Chandelle Estates Airport ... private RJR Airdrome Roger Kruser public
5 6 0N5 Heliport DelDOT Helistop ... public Delaware Department of Transportation (DelDOT) DelDOT Office of Aeronautics public
6 7 DOV Air Force Base DAFB & Civil Air Terminal ... military United States Air Force (USAF) United States Air Force (USAF) controlled
7 8 15N Airport Jenkins Airport ... private Joe C. Jenkins Joe C. Jenkins public
8 9 D74 Airport Chorman Airport ... private Allen Chorman Allen Chorman public
9 10 GED Airport Sussex County Airport ... public Sussex County Sussex County public
10 11 N06 Airport Laurel Airport ... private DEST Inc. ACFT Inspection & Maintenance public