-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add raw tweets in datacollection page
- Loading branch information
hyang
authored and
hyang
committed
Aug 23, 2013
1 parent
4ebf36b
commit 481610b
Showing
2 changed files
with
59 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
// Config | ||
$dbhost = 'localhost'; | ||
$dbname = 'data'; | ||
$task_id = 2; | ||
// Connect to test database | ||
$m = new Mongo("mongodb://$dbhost"); | ||
$db = $m->$dbname; | ||
|
||
// select a collection (analogous to a relational database's table) | ||
$collection = $db->libya; | ||
|
||
//count the number of items in this collection | ||
echo '<h3>The entire collection has ', $collection->count(), ' tweets'; | ||
|
||
// condition $query | ||
$nullgeolat = "0.00000"; | ||
|
||
$query = array("geo_lat" => array('$ne' => $nullgeolat)); | ||
|
||
$cursor = $collection->find($query)->limit(1000); | ||
|
||
//count the number of items in this query | ||
echo '; This query returns ', $cursor->count(), ' geo-tagged tweets</h3>'; | ||
|
||
echo '<center><h4>The 1000 samples are as follows</h3></center><hr>'; | ||
|
||
echo '<table cellpadding="0" cellspacing="0" class="db-table">'; | ||
echo '<tr> | ||
<th>Index</th> | ||
<th>Lat </th> | ||
<th>Long </th> | ||
<th>Tweet </th> | ||
</tr>'; | ||
|
||
// iterate geo info with tweets | ||
$index = 1; | ||
|
||
foreach ($cursor as $document) { | ||
echo '<tr>'; | ||
echo '<td>',$index,'</td>'; | ||
$index++; | ||
echo '<td>',$document["geo_lat"],'</td>'; | ||
echo '<td>',$document["geo_long"],'</td>'; | ||
echo '<td>',$document["tweet_text"],'</td>'; | ||
echo '<tr>'; | ||
|
||
// echo $document["tweet_id"],' ',$document["tweet_text"],' ',$document["geo_lat"],'',$document["geo_long"]; | ||
|
||
} | ||
|
||
?> | ||
|
||
|
||
</body> | ||
</html> |
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