[Python] 엑셀 파일 불러오기 ValueError

양승우·2024년 10월 18일

Python

목록 보기
4/16

파이썬 파일 저장하기/불러오기 과정에서 에러가 발생했다.

import pandas as pd

df_csv = pd.read_csv('/content/drive/MyDrive/Bootcamp/Sparta_Colab/files/test_data.csv')
df_json = pd.read_json('/content/drive/MyDrive/Bootcamp/Sparta_Colab/files/test_data.json')

df_xls = pd.read_excel('/content/drive/MyDrive/Bootcamp/Sparta_Colab/files/test_data.xlsx')
### ValueError: Excel file format cannot be determined, you must specify an engine manually.

ValueError...
csv나 json 파일은 잘 작동하는 데 xlsx에서만 발생하는 에러

에러 코드를 보니 excel file format이 결정될 수 없다... 사실 정확히는 이해 못했지만
그냥 갑자기 퍼뜩 지나간 생각이,
파일에 문제가 있나?

그래서 그냥 파일을 엑셀로 열어보려고 하니까 파일을 열 수 없다더라
단순히 파일이 저장 과정에서 모종의 이유로 깨졌었던 것 같다;;

다시 저장하고 실행시켜보니 에러 없이 파일 불러오기가 잘 진행되었다

결론.
파일은 저장했으면 한 번 잘 열리는 지 확인해보자

profile
어제보다 오늘 더

0개의 댓글