- 이미 존재하는 DB에 psql로 데이터를 넣다보면 Integrity Error 가 발생할 떄가 있다. 근데 psql 옵션에는 각 한줄 한줄의 error를 무시할 수 있는 옵션이 없다.
- 그냥 바로 넣기 때문인데... 이것 때문에 짜증이 나서 파이썬으로 한줄씩 읽으면서 DB에 넣고 Error가 발생하면 그 Data는 무시할 수 있게끔 했다.
- 끝까지 넣기만 하면 되는거다. Data 정합성이 중요하다면 이렇게 하면 안되지만 정합성이 중요하지 않은 Data들에서는 충분히 쓸만한 소스다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import docx | |
| from docx.document import Document | |
| from docx.oxml.table import CT_Tbl | |
| from docx.oxml.text.paragraph import CT_P | |
| from docx.table import _Cell, Table | |
| from docx.text.paragraph import Paragraph | |
| os.chdir('C:\\OJT_Kevin\\161027_docx_parsing') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from .models import Url | |
| def get_columns(line): | |
| column_str = re.search(r'COPY [-_\w\.]+ \(([^\)]+)\)', line).group(1) | |
| columns = column_str.split(',') | |
| return [column.strip() for column in columns] | |
| def is_start(text): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from .models import Url | |
| def get_columns(line): | |
| column_str = re.search(r'COPY [-_\w\.]+ \(([^\)]+)\)', line).group(1) | |
| columns = column_str.split(',') | |
| return [column.strip() for column in columns] | |
| def is_start(text): |
- http://www.yes24.com/24/goods/63503495?scode=032&OzSrank=1: 장고 기초책
- http://www.yes24.com/24/goods/29331035?scode=032&OzSrank=3: 장고 실전책
- https://www.askcompany.kr/: 무료 강의 있으니까 일단 이걸로 보는 것도 좋음
- 동영상 강의가 꽤 좋음. 강사님 말씀은 약간 새는 편이긴 한데. 책에서는 나오지 않는 세세한 코드도 보여주고 많은 활용방법들을 보여줘서 괜찮음.
- 여기 있는 전부를 2~3번 정도 따라하면 기초가 어느 정도 쌓이기 때문에 괜찮음. 이 정도만 되면 ok.
- http://www.yes24.com/24/goods/30355215?scode=032&OzSrank=2: 장고의 Best Practice
-
정규 표현식 질문 하나 드릴게요. 이거 의외로 간단한거 같은데 잘 안되네요.
-
여기에서 제일 앞에 http://naver.com/path/ab1.html 이것만 가져올 수 있는 방법이 없을까요?
OlderNewer