Skip to content

Instantly share code, notes, and snippets.

@catwhocode
Created November 29, 2020 08:20
Show Gist options
  • Save catwhocode/2238e99c6693f0820015265f3e9afb58 to your computer and use it in GitHub Desktop.
Save catwhocode/2238e99c6693f0820015265f3e9afb58 to your computer and use it in GitHub Desktop.
import csv
import urllib.request
url = input('Masukkan URL tempat file .CSV berada: ')
cari = input('Data yang akan anda cari: ')
nama_file = "file.csv"
pemisah = ";";
req = urllib.request.Request(url)
with urllib.request.urlopen(req) as response:
data = response.read()
text = data.decode("utf-8")
with open(nama_file, 'wb') as f:
f.write(data)
with open(nama_file) as csv_file:
csv_reader = csv.reader(csv_file,delimiter=pemisah)
ketemu = False
for row in csv_reader:
isi = row[0]
kolom2 = row[1]
gabung = isi + " " + kolom2
if isi == cari:
print('Kata ' + cari + ' telah ditemukan -> ' + gabung)
ketemu = True
break
if ketemu == False:
print('Kata ' + cari + ' TIDAK ditemukan')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment