This file contains 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 tabula | |
pdf_path = "PMDN 72 TH 2019+lampiran.pdf" | |
output = tabula.read_pdf( | |
input_path =pdf_path, | |
pages="8", | |
output_format="json" | |
) | |
print(output) |
This file contains 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
D:\python\venv\indonesia_region\Scripts\python.exe D:/python/project/indonesia_region/main.py | |
[{'extraction_method': 'lattice', 'top': 96.0, 'left': 37.350002, 'width': 879.91845703125, 'height': 470.70013427734375, 'right': 917.26843, 'bottom': 566.70013, 'data': [[{'top': 96.0, 'left': 37.350002, 'width': 52.64999771118164, 'height': 48.0, 'text': 'K O D E'}, {'top': 96.0, 'left': 90.0, 'width': 144.0, 'height': 48.0, 'text': 'NAMA PROVINSI /\rKABUPATEN / KOTA'}, {'top': 96.0, 'left': 234.0, 'width': 60.0, 'height': 24.0, 'text': 'JUMLAH'}, {'top': 96.0, 'left': 294.0, 'width': 306.0, 'height': 24.0, 'text': 'N A M A/J U M L A H'}, {'top': 96.0, 'left': 600.0, 'width': 54.0, 'height': 48.0, 'text': 'LUAS\rWILAYAH\r(Km2)'}, {'top': 96.0, 'left': 654.0, 'width': 53.45452880859375, 'height': 48.0, 'text': 'JUMLAH\rPENDUDUK\r(Jiwa)'}, {'top': 96.0, 'left': 707.4545, 'width': 209.81390380859375, 'height': 48.0, 'text': 'K E T E R A N G A N'}, {'top': 0.0, 'left': 0.0, 'width': 0.0, 'height': 0.0, 'text': ''}, {' |
This file contains 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 tabula | |
pdf_path = "PMDN 72 TH 2019+lampiran.pdf" | |
tabula.convert_into( | |
input_path=pdf_path, | |
output_path="aceh_page_8.csv", | |
output_format="csv", | |
pages="8" | |
) |
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 3.
This file contains 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
K O D E,"NAMA PROVINSI / | |
KABUPATEN / KOTA",JUMLAH,N A M A/J U M L A H,"LUAS | |
WILAYAH | |
(Km2)","JUMLAH | |
PENDUDUK | |
(Jiwa)",K E T E R A N G A N,,, | |
"",KAB,KOTA,KECAMATAN,KELURAHAN,D E S A,,,, | |
11,ACEH,,,,,,,,"UU. No. 11 Tahun 2006 | |
Perbaikan nama sesuai Surat Pemkab Aceh Selatan | |
No.140/819/2016 tgl 14 okt 2016 dan Rekomedasi Ditjen Bina |
This file contains 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 tabula | |
pdf_path = "PMDN 72 TH 2019+lampiran.pdf" | |
tabula.convert_into( | |
input_path=pdf_path, | |
output_path="aceh.csv", | |
output_format="csv", | |
pages="8-274" | |
) |
We can't make this file beautiful and searchable because it's too large.
This file contains 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
K O D E,"NAMA PROVINSI / | |
KABUPATEN / KOTA",JUMLAH,N A M A/J U M L A H,"LUAS | |
WILAYAH | |
(Km2)","JUMLAH | |
PENDUDUK | |
(Jiwa)",K E T E R A N G A N,,, | |
"",KAB,KOTA,KECAMATAN,KELURAHAN,D E S A,,,, | |
11,ACEH,,,,,,,,"UU. No. 11 Tahun 2006 | |
Perbaikan nama sesuai Surat Pemkab Aceh Selatan | |
No.140/819/2016 tgl 14 okt 2016 dan Rekomedasi Ditjen Bina |
This file contains 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 tabula | |
pdf_path = "PMDN 72 TH 2019+lampiran.pdf" | |
output_folder = "csv/" | |
region_list = [ | |
# sumatera | |
{"file": output_folder + "11-aceh.csv", "pages": "8-274"}, | |
{"file": output_folder + "12-sumut.csv", "pages": "287-582"}, | |
{"file": output_folder + "13-sumbar.csv", "pages": "601-653"}, |
This file contains 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 csv | |
import json | |
province = [] # provinsi | |
regency_or_city = [] # kabupaten or kota | |
district = [] # kecamatan | |
administrative_village_or_village = [] # kelurahan or desa | |
# check if string has a number | |
def hasANumber(inputString): |
This file contains 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
{ | |
"province": [ | |
{ | |
"prov_code": "11", | |
"prov_name": "ACEH" | |
} | |
], | |
"regency_or_city": [ | |
{ | |
"kab_code": "11.01", |
This file contains 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
[ | |
{ | |
"prov_code": "11", | |
"prov_name": "ACEH" | |
} | |
] |
OlderNewer