Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/JoelKlint/twitter-geoloca…
- Loading branch information
Showing
3 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import psycopg2 | ||
import functools | ||
import datetime | ||
|
||
# Connect to the db | ||
conn = psycopg2.connect("dbname=twitter-geo") | ||
|
||
|
||
# Fetch stuff from db | ||
cur = conn.cursor() | ||
cur.execute('select distinct(created_at) from tweets;') | ||
result = cur.fetchall() | ||
cur.close() | ||
# Get rid of tuples | ||
result = list(map(lambda a: a[0], result)) | ||
# Work on a minute level | ||
result = list(map(lambda a: a.replace(second=0, microsecond=0), result)) | ||
# Remove duplicates | ||
result = set(result) | ||
# Convert to list | ||
result = list(result) | ||
# Sort | ||
result = sorted(result) | ||
|
||
# Find non aligned values | ||
for i in range(len(result)): | ||
# Convert to seconds | ||
if(i == 0): | ||
continue | ||
|
||
# Get the two values | ||
start = result[i-1] | ||
end = result[i] | ||
|
||
# Convert to seconds | ||
a = start.timestamp() | ||
b = end.timestamp() | ||
|
||
# Print non aligned values | ||
if(b-a != 60): | ||
print("FOUND HOLE") | ||
print("Last insert time: {}".format(start)) | ||
print("First insert time: {}".format(end)) | ||
print("") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters