Lecture 12 - CSV와 SQL
- Google Analytics에서 AB Test를 하는 경우 landing page 자체를 자리게 하고 있으므로, 이를 통해 segment 분석이 가능해 짐
파일 다운로드
- wgethttps://dl.dropboxusercontent.com/u/8906188/fastcamp/customer.csv
- wgethttps://dl.dropboxusercontent.com/u/8906188/fastcamp/product.csv
- wgethttps://dl.dropboxusercontent.com/u/8906188/fastcamp/tx.csv
csvsort-cagecustomer.csv|csvlook
SQL?
● Structured Query Language
● RDBMS(Relational Database Management System)의 데이터를 조작하기 위한 선언적 언어(declarative language)
● RDBMS? 세상에서 가장 널리 쓰이는 데이터 저장/질의/관리 시스템. 관계대수(relation algebra)에 기반을 둔 이론적으로 탄탄한 접근법
● 선언적? “어떻게 하겠다"가 아니라 “무엇을 하겠다(선언)"를 적으면 어떻게 할지는 기계가 알아서 수행
○ 어떻게: 진공청소기로 청소를 한 번 하고 물걸레질을 한다. (Python)
○ 무엇을: 방에 먼지가 없어야 한다 (SQL)
ubuntu@ip-172-31-47-3:~$ csvcut -c name,age customer.csv\?hc_location\=ufi
ubuntu@ip-172-31-47-3:~$ csvcut -c name,age customer.csv\?hc_location\=ufi |head -n 6| csvlook
ubuntu@ip-172-31-47-3:~$ csvstat customer.csv\?hc_location\=ufi
ubuntu@ip-172-31-47-3:~$ csvsort -c age customer.csv\?hc_location\=ufi |csvlook
ubuntu@ip-172-31-47-3:~$ csvsort -c age -r customer.csv\?hc_location\=ufi |csvlook
ubuntu@ip-172-31-47-3:~$ csvsql customer.csv\?hc_location\=ufi --query "SELECT age, gender FROM customer;"|csvlook
query() { csvsql customer.csv\?hc_location\=ufi product.csv\?hc_location\=ufi tx.csv\?hc_location\=ufi --query "$1" | csvlook;}
query "SELECT * FROM customer;"
query "select name,age from customer;"
query "select name,age from customer where age>30;"
ubuntu@ip-172-31-47-3:~$ query "select name,age from customer where age>30;"
ubuntu@ip-172-31-47-3:~$ query "select name,age from customer where age>30 and gender='F';"
ubuntu@ip-172-31-47-3:~$ query "select name,age from customer where gender='F' order by age;"
ubuntu@ip-172-31-47-3:~$ query "select name,age from customer where gender='F' order by age desc ;"
'Fast Camp_DA' 카테고리의 다른 글
Fast Campus: Data Analytics 17일차 (4/22) Part 1 (0) | 2015.04.22 |
---|---|
Fast Campus: Data Analytics 16일차 (4/19) Part 2 (0) | 2015.04.19 |
Fast Campus: Data Analytics 15일차 (4/15) (0) | 2015.04.15 |
Fast Campus: Data Analytics 15일차 (4/15) (0) | 2015.04.15 |
Fast Campus: Data Analytics 14일차 (4/12) (0) | 2015.04.15 |