RWET – Loops and Lists

This week in Reading and Writing Electronic Text I worked with loops and lists to make a script that breaks a series of headlines up into a sort of 24 hour clock. The idea is that each headline its slowly revealed over the course of a day as a play on the idea of the 24 hour news cycle.

I started with a text file that contained headlines from a bunch of large news outlets:

PROBLEM OF THEIR OWN Canada sees spike in border crossings from US
Rex Tillerson Arrives in Mexico Facing Twin Threats to Relations
Kim Jong-nam killing: North Korea condemns Malaysia
ACLU Sues Milwaukee Over Police Stop-and-Frisk Policy
Trump Meets With Corporate CEOs Thursday on Economic Policies
Bannon told EU it was flawed just before Pence’s visit
7 potentially habitable exoplanets discovered
2 cops charged in Florida woman’s accidental shooting death
Obama-linked activists have a ‘training manual’ for protesting Trump

I then shuffled the order of the headlines (to keep the output interesting) and broke each line into a list of words. The number of words in each line was used to figure out how to display it over the course of a day and then each word is designated a time slot. I created a loop to simulate a 24 hour cycle with this method. I imagine this could be a part of an installation that would act live a very slow moving new ticker.

The code:

import sys
import random
all_lines = []
minutes = -60
lines = []

for l in sys.stdin:
lines.append(l.strip())

random.shuffle(lines)

for line in lines:
line = line.strip()
word = line.split(” “)
all_lines.append(word)

for x in range(24):
wordTimerForEachHeadline = []
currentWordNum=[]
minutes+=60
print “\n”,
print “Today’s Headlines”,
print str(minutes/60)+(“:00”)
for i in range(len(all_lines)):
wordTimerForEachHeadline.append(1440/(len(all_lines[i])))
currentWordNum.append(minutes / wordTimerForEachHeadline[i])
print all_lines[i][currentWordNum[i]]

The output:

Today’s Headlines 0:00

Trump

Obama-linked

7

ACLU

Rex

PROBLEM

Bannon

Kim

2

Today’s Headlines 1:00

Trump

Obama-linked

7

ACLU

Rex

PROBLEM

Bannon

Kim

2

Today’s Headlines 2:00

Trump

Obama-linked

7

ACLU

Rex

OF

Bannon

Kim

2

Today’s Headlines 3:00

Meets

activists

7

ACLU

Tillerson

OF

told

Kim

cops

Today’s Headlines 4:00

Meets

activists

7

Sues

Tillerson

THEIR

told

Jong-nam

cops

Today’s Headlines 5:00

Meets

activists

potentially

Sues

Arrives

THEIR

EU

Jong-nam

cops

Today’s Headlines 6:00

With

have

potentially

Sues

Arrives

OWN

EU

Jong-nam

charged

Today’s Headlines 7:00

With

have

potentially

Milwaukee

Arrives

OWN

EU

killing:

charged

Today’s Headlines 8:00

Corporate

a

potentially

Milwaukee

in

Canada

it

killing:

in

Today’s Headlines 9:00

Corporate

a

potentially

Milwaukee

in

Canada

it

killing:

in

Today’s Headlines 10:00

Corporate

a

habitable

Milwaukee

Mexico

sees

was

killing:

in

Today’s Headlines 11:00

CEOs

‘training

habitable

Over

Mexico

sees

was

North

Florida

Today’s Headlines 12:00

CEOs

‘training

habitable

Over

Facing

spike

flawed

North

Florida

Today’s Headlines 13:00

CEOs

‘training

habitable

Over

Facing

spike

flawed

North

Florida

Today’s Headlines 14:00

Thursday

manual’

habitable

Police

Facing

in

flawed

Korea

woman’s

Today’s Headlines 15:00

Thursday

manual’

exoplanets

Police

Twin

in

just

Korea

woman’s

Today’s Headlines 16:00

on

for

exoplanets

Police

Twin

border

just

Korea

accidental

Today’s Headlines 17:00

on

for

exoplanets

Police

Threats

border

before

Korea

accidental

Today’s Headlines 18:00

on

for

exoplanets

Stop-and-Frisk

Threats

crossings

before

condemns

accidental

Today’s Headlines 19:00

Economic

protesting

exoplanets

Stop-and-Frisk

Threats

crossings

before

condemns

shooting

Today’s Headlines 20:00

Economic

protesting

discovered

Stop-and-Frisk

to

from

Pence’s

condemns

shooting

Today’s Headlines 21:00

Economic

protesting

discovered

Policy

to

from

Pence’s

Malaysia

shooting

Today’s Headlines 22:00

Policies

Trump

discovered

Policy

Relations

US

visit

Malaysia

death

Today’s Headlines 23:00

Policies

Trump

discovered

Policy

Relations

US

visit

Malaysia

death

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *