이제 데이터를 살펴보겠습니다. 데이터가 저장된 CSV 파일을 불러와 한 행씩 출력해 볼까요?
import csv f = open('subwaytime.csv') data = csv.reader(f) for row in data : print(row)
실행 결과
['사용월', '호선명', '역ID', '지하철역', '04:00:00~04:59:59', '', '05:00:00~05:59:59', '', '06:00:00~06:59:59', '', '07:00:00~07:59:59', '', '08:00:00~08:59:59', '', '09:00:00~09:59:59', '', '10:00:00~10:59:59', '', '11:00:00~11:59:59', '', '12:00:00~12:59:59', '', '13:00:00~13:59:59', '', '14:00:00~14:59:59', '', '15:00:00~15:59:59', '', '16:00:00~16:59:59', '', '17:00:00~17:59:59', '', '18:00:00~18:59:59', '', '19:00:00~19:59:59', '', '20:00:00~20:59:59', '', '21:00:00~21:59:59', '', '22:00:00~22:59:59', '', '23:00:00~23:59:59', '', '00:00:00~00:59:59', '', '01:00:00~01:59:59', '', '02:00:00~02:59:59', '', '03:00:00~03:59:59', '', ''] ['', '', '', '', '승차', '하차', '승차', '하차', '승차', '하차', '승차', '하차', '승차', '하차', '승차', '하차', '승차', '하차', '승차', '하차', '승차', '하차', '승차', '하차', '승차', '하차', '승차', '하차', '승차', '하차', '승차', '하차', '승차', '하차', '승차', '하차', '승차', '하차', '승차', '하차', '승차', '하차', '승차', '하차', '승차', '하차', '승차', '하차', '승차', '하차', '승차', '하차', ''] ['2019-01', '1호선', '0150', '서울역', '927', '22', '10682', '8774', '13504', '45545', '39110', '103863', '80492', '236747', '61108', '163026', '68446', '86198', '89100', '80051', '98021', '85869', '101282', '91792', '86627', '86386', '113919', '87211', '118223', '91594', '161216', '98032', '249973', '105075', '142575', '77807', '97729', '55056', '96955', '46680', '70982', '35481', '33149', '19442', '3612', '7167', '0', '410', '0', '0', '0', '0', ''] (생략)