Project

data set from hacker news

In [3]:
from csv import reader
opened_file = open('hacker_news.csv')
read_file = reader(opened_file)
hn = list(read_file)
for row in hn[:5]:
    print(row)
    
headers = row[0]
hn = row[1:]
print(headers)
for row in hn:
    print(row)
    
ask_posts = []
show_posts = []
other_posts = []

for row in hn:
    title = row[1]
    if title.lower().startswith('ask hn'):
        ask_posts.append(row)
    elif title.lower().startswith('show hn'):
        show_posts.append(row)
    else:
        other_posts.append(row)
        
print(len(ask_posts))
print(len(show_posts))
print(len(other_posts))
['id', 'title', 'url', 'num_points', 'num_comments', 'author', 'created_at']
['12224879', 'Interactive Dynamic Video', 'http://www.interactivedynamicvideo.com/', '386', '52', 'ne0phyte', '8/4/2016 11:52']
['10975351', 'How to Use Open Source and Shut the Fuck Up at the Same Time', 'http://hueniverse.com/2016/01/26/how-to-use-open-source-and-shut-the-fuck-up-at-the-same-time/', '39', '10', 'josep2', '1/26/2016 19:30']
['11964716', "Florida DJs May Face Felony for April Fools' Water Joke", 'http://www.thewire.com/entertainment/2013/04/florida-djs-april-fools-water-joke/63798/', '2', '1', 'vezycash', '6/23/2016 22:20']
['11919867', 'Technology ventures: From Idea to Enterprise', 'https://www.amazon.com/Technology-Ventures-Enterprise-Thomas-Byers/dp/0073523429', '3', '1', 'hswarna', '6/17/2016 0:01']
11919867
Technology ventures: From Idea to Enterprise
https://www.amazon.com/Technology-Ventures-Enterprise-Thomas-Byers/dp/0073523429
3
1
hswarna
6/17/2016 0:01
IndexErrorTraceback (most recent call last)
<ipython-input-3-f569afc6fc95> in <module>()
     17 
     18 for row in hn:
---> 19     title = row[1]
     20     if title.lower().startswith('ask hn'):
     21         ask_posts.append(row)

IndexError: string index out of range