반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 왕초보 파이썬 실행
- Selenium 셀렉터잡기
- UiPath
- 파이썬 환경설정
- 파이썬 가상환경 설치
- 파이썬네이버부동산
- Python
- 파이썬 가상환경 설치방법
- 네이버매물크롤링
- pycdas.exe
- 네이버부동산크롤링
- pywinauto 윈도우제어
- 네이버 로그인 캡챠해결
- 파이썬 네이버 로그인
- Uipath 설치방법
- 네이버 로그인 영수증 해결
- 날짜 정규식
- Element is not clickable at point
- pycdc.exe
- 가상환경설치
- vscode venv 설치
- selenium
- Uipath 기초
- 네이버 로그인 하기
- 커머스API
- pywinauto 윈도우
- uipath 입문
- 네이버커머스API
- pywinauto
- venv 설치
Archives
- Today
- Total
콘솔워크
개인적으로 권장하는 엑셀 파일 dataframe화 방식 본문
반응형
if 1 == 1:
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
import os
import pandas as pd
class OrderFile:
def __init__(self, filepath):
self.filepath = filepath
self.initData()
def get_excel_data_type(self):
return {
"열1": str,
"열2": str,
"열3": str,
}
def initData(self):
self.filepath = os.path.normpath(self.filepath)
self.filename = os.path.basename(self.filepath)
columns = self.get_excel_data_type()
try:
self.df_order = pd.read_excel(self.filepath, converters=columns, keep_default_na="")
self.df_order = self.df_order.loc[:, list(columns.keys())]
except Exception as e:
print(e)
def output(self):
print(self.df_order)
if __name__ == "__main__":
order_file = OrderFile(r"D:\excels\엑셀.xlsx")
order_file.output()
열의 이름을 해당 클래스에서 미리 입력받아 놓으면 추후 유지보수에 편리하다.
예) 엑셀에 열을 추가해서 다른 기능을 추가하고 싶다... 등
반응형
'프로그래밍 > python' 카테고리의 다른 글
APScheduler 특정 시간에 함수 실행을 예약하고 예약을 취소하는 방법 (0) | 2023.01.17 |
---|---|
for문에서 각각 변수명을 선언하는 방법 (0) | 2023.01.16 |
비동기 처리 (0) | 2023.01.12 |
string이 특정 html 태그 안에 있는지 확인해보는 정규식 (0) | 2023.01.12 |
json 파일 다루기 (0) | 2023.01.11 |