| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
- Python
- Java
- Kotlin
- string
- PANDAS
- 파이썬
- Excel
- math
- list
- GIT
- google apps script
- PySpark
- Tkinter
- SQL
- hive
- c#
- Apache
- array
- Google Excel
- Redshift
- django
- Github
- gas
- Google Spreadsheet
- dataframe
- PostgreSQL
- matplotlib
- numpy
- Presto
- Today
- Total
목록Python (393)
달나라 노트
pathlib에서 suffix 속성을 이용하면 파일의 확장자를 받을 수 있습니다. from pathlib import Pathdir_path = '/Users/Documents/code/pythonProject/h_2.py'# Create a Path objectobj_path = Path(dir_path)# Get extension through suffix attributeextension = obj_path.suffix# Show extensionprint(extension)-- Result.py - obj_path = Path(dir_path)먼저 Path를 통해 특정 directory에 존재하는 파일에 대한 object를 만듭니다.그러면 이 object에는 파일에 대한 다양한 정보가 담겨있게 ..
os.path.isfile()은 주어진 경로가 파일인지 아닌지를 return합니다. os.path.isfile(directory) 사용법은 위와 같습니다.directory가 파일이라면 True를 return합니다.directory가 파일이 아니라면 False를 return합니다. import ostarget_dir = '/Users/Documents/code/pythonProject/gemini_test.py' # 1bool_file_yn = os.path.isfile(target_dir) # 2print(bool_file_yn)-- ResultTrue 1. 체크할 directory를 준비합니다. 2. os.path.isfile() method를 이용하여 directory의 파일 여부를 체크합니다..
간혹 어떤 기준되는 폴더 안에 있는 모든 파일 list를 얻고 싶을 때가 있습니다.근데 단순히 어떤 폴더 안에 담긴 것이 아니라 폴더 속 폴더 속 폴더 속의 파일 같이 다중으로 구성된 directory의 모든 파일 리스트를 얻고싶을 때가 있죠.이때는 iglob를 사용하면 유용합니다. glob.iglob(directory, recursive=True/False) 사용법은 위와 같습니다.잘 모르겠으니 예시를 통해서 알아봅시다. 예시에서의 목적은 다음과 같습니다."내가 원하는 폴더 안에 있는 모든 파일과, 모든 폴더 속에 담긴 파일까지 모두 return하라." import glob# 기준 folderroot_path = '/Users/Documents/code/pythonProject/**' # 1# ..
anaconda를 사용할 때 다양한 environment를 어떻게 활성화하는지 알아봅시다. conda activate environment_name 원하는 interpreter를 활성화할 땐 conda activate 명령어를 사용하면 됩니다. 예시를 봅시다. terminal을 열고 conda env list를 입력하여 현재 제 컴퓨터에 설치된 conda environment를 출력해봅시다.(conda env list 관련 = https://cosmosproject.tistory.com/919) (base) ~ % conda env list# conda environments:#base * /opt/anaconda3dj_project /opt/a..