1. XML 분석 : BeautifulSoup
xml = open(filename, "r", encoding="utf-8").read() soup = BeautifulSoup(xml, 'html.parser') info = {} for location in soup.find_all("location"): name = location.find('city').string weather = location.find('wf').string if not (weather in info): info[weather[ = [] info[weather].append(name) for weather in info.keys(): print("+", weather) for name in info[weather]: print("| - ", name)
2. JSON 분석 : json (기본 라이브러리)
import urllib.request as req import os.path, random import json #JSON 데이터 내려받기 url = 'https://api.github.com/repositories" savename = "repo.json" if not os.path.exists(url): req.rulretrieve(url, savename) #JSON 파일 분석하기 items = json.load(open(savename, "r", encoding="utf-8")) # 또는 # s = open(savename, "r", encoding="utf-8").read() # items = json.loads(s) #출력하기 for item in items: print(item["name"] + " - " + item["owner]["login])
2. YAML 분석 : yaml (기본 라이브러리)
3. csv/tsv 분석 : cvs, codecs (기본 라이브러리), Pandas and xlrd(엑셀 수정 가능토록 하는 모듈)
$ pip3 install pandas
$ pip3 install xlrd
4. 엑셀파일 분석 : openpyxl
$ pip3 install openpyxl
or
C:\Python34\Scripts\pip3.exe install openpyxl
'프로그래밍 > Python' 카테고리의 다른 글
[요약]파이썬(Python) 문자형 처리 (0) | 2020.09.01 |
---|---|
[요약]파이썬(Python) 가상환경 설정 및 패키지 설치 (0) | 2020.08.31 |
[요약]파이썬(Python) 코딩 둘러보기 (0) | 2020.08.31 |
[요약]파이썬(Python) Print함수의 이해 (0) | 2020.08.31 |
[요약] 파이썬(Python) 개발환경 설정 - Windows (0) | 2020.08.31 |