Fakultas Ilmu Komputer UI

Commit e7c74f67 authored by Ahmad Dzikrul Fikri's avatar Ahmad Dzikrul Fikri
Browse files

Tugas Pemrograman 9 - Soal 2

parent 1443e4b7
def simpan_db():
import time
def simpan_file():
try:
import kvdb
result_f = open("input_order2.txt")
result_f = open("pembeli.txt")
data_baru = open('TP9_2_1806196806.txt', 'w')
for line in result_f:
line = line.replace('\n','')
name, jumlah = line.split()
kvdb.db_set('UhHzASg8tRdxHtYqiQxrQ3',name,jumlah)
result_f.close()
s = {}
line = line.replace('/n','')
(id_pelanggan, s['nama_depan'], s['nama_belakang'], s['tempat_tinggal'], s['jumlah_pembelian'], s['level_keanggotaan']) = line.split()
for keys in s:
data_baru.write('pembeli:'+id_pelanggan+':'+keys+'='+s[keys]+'\n')
data_baru.close()
except TypeError:
print('input ke dalam file harus berupa string')
except FileNotFoundError:
print('\nFile tidak ditemukan')
print('Pastikan file pembeli.txt berada dalam folder yang sama dengan script ini')
print('Pastikan juga terminal anda terhubung dengan folder ini\n')
print('keluar dari program')
except :
print('koneksi internet hilang')
simpan_db()
\ No newline at end of file
simpan_file()
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment