Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

contextlib closing python file

from contextlib import closing
import csv
# STEP 1: 
# Baca file "harga_rumah.txt"
url = "url"
data = []
with closing(requests.get(url, stream=True)) as r:
    f = (line.decode('utf-8') for line in r.iter_lines())
    data = [row for row in csv.reader(f)]
 
PREVIOUS NEXT
Tagged: #contextlib #closing #python #file
ADD COMMENT
Topic
Name
5+4 =