Sie sind auf Seite 1von 14

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/324172651

Materi Pengenalan Python untuk Meteorologi Pertemuan 2 : Format


Waktu Membaca dan Menulis File Akses dan Manipulasi File/Direktori
Download File

Presentation · August 2017


DOI: 10.13140/RG.2.2.33784.14088

CITATIONS READS

0 172

1 author:

Alpon Sepriando
Meteorological Climatological and Geophysical Agency
13 PUBLICATIONS   15 CITATIONS   

SEE PROFILE

Some of the authors of this publication are also working on these related projects:

Simotera : Earthquake Precursors Monitoring System Based on TEC and Radon Data View project

All content following this page was uploaded by Alpon Sepriando on 03 April 2018.

The user has requested enhancement of the downloaded file.


Pertemuan 2
Format Waktu
Membaca dan Menulis File
Akses dan Manipulasi File/Direktori
Download File
Alpon Sepriando
Meteo.go@gmail.com
FORMAT WAKTU
Latihan 1

Tentukan hari, tanggal dan bulan pada 799 hari lagi?

Kunci : Timedelta
Membaca File txt

Sintaks : file object = open(file_name [, access_mode])

Contoh : fo = open(‘data1.txt’,’r’)
access_mode :
‘r’ – Read mode which is used when the file is only being
read
‘w’ – Write mode which is used to edit and write new
information to the file (any existing files with the same name
will be erased when this mode is activated)
Membaca file CSV
Menulis File
1 2

3 4
Latihan 2

Buatlah sebuat file seperti diatas dengan menggunakan


skrip python? Gunakan
Akses dan Manipulasi File/Direktori

>>>import os

os.path >>>from os import path


Latihan 3

1. Buatlah sebuah folder pada suatu direktori(bebas) dengan


nama tahun saat ini, didalamnya terdapat folder 01,02
hingga 12. Gunakan skrip

2. Hapus salah satu direktori pada soal diatas

3. Ganti nama file pada Latihan 2 menjadi data_[nama


sendiri].txt

Kunci:
1. datetime, mkdir
Download File

Ada beberapa cara, cara yang


umum:

urllib.urlretrieve ('url_to_file’,’ file_name’)

Contoh :
Download Multiple File

Gunakan module fileDownloader


karena memiliki fitur yang
lengkap dan stabil
https://pypi.python.org/pypi/fil
eDownloader.py/0.2.1
Latihan 4

Download data GSMAP tanggal 8 September 2016

ftp://hokusai.eorc.jaxa.jp

Username : ***** [silakan register]

Password : ***** [silakan register]


View publication stats

Das könnte Ihnen auch gefallen