-
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.
Merge pull request #25 from CAIDA/py3
Update python3 version
- Loading branch information
Showing
10 changed files
with
113 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,14 @@ | |
|
||
setuptools.setup( | ||
name='pywandio', | ||
version='0.2.1', | ||
version='0.3.0', | ||
description='High-level file IO library', | ||
url='https://github.com/CAIDA/pywandio', | ||
author='Alistair King, Chiara Orsini, Mingwei Zhang', | ||
author_email='[email protected]', | ||
packages=setuptools.find_packages(), | ||
install_requires=[ | ||
'python-dotenv', | ||
'python-keystoneclient', | ||
'python-swiftclient', | ||
], | ||
|
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,19 @@ | ||
import wandio | ||
|
||
if __name__ == '__main__': | ||
|
||
with wandio.open('test.txt.gz') as fh: | ||
line_count = 0 | ||
word_count = 0 | ||
for line in fh: | ||
word_count += len(line.rstrip().split()) | ||
line_count +=1 | ||
print(line_count, word_count) | ||
|
||
with wandio.open('test.txt.gz', "rb") as fh: | ||
line_count = 0 | ||
word_count = 0 | ||
for line in fh: | ||
word_count += len(line.rstrip().split()) | ||
line_count +=1 | ||
print(line_count, word_count) |
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,13 @@ | ||
import wandio | ||
|
||
if __name__ == '__main__': | ||
|
||
with wandio.open('http://data.caida.org/datasets/as-relationships/README.txt') as fh: | ||
with wandio.open('test.txt.gz', mode='w') as ofh: | ||
line_count = 0 | ||
word_count = 0 | ||
for line in fh: | ||
word_count += len(line.rstrip().split()) | ||
line_count +=1 | ||
ofh.write(line) | ||
print(line_count, word_count) |
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,40 @@ | ||
import wandio | ||
from dotenv import load_dotenv, find_dotenv | ||
import os | ||
|
||
if __name__ == '__main__': | ||
|
||
files = [ | ||
# 'swift://datasets-external-netacq-codes/country_codes.csv', | ||
# 'https://www.caida.org/~mingwei/', | ||
# 'http://data.caida.org/datasets/as-relationships/README.txt', | ||
# 'http://loki.caida.org:2243/data/external/as-rank-ribs/19980101/19980101.as-rel.txt.bz2', | ||
# '/home/mingwei/moas.1601006100.events.gz', | ||
'swift://bgp-hijacks-edges/year=2020/month=09/day=30/hour=11/edges.1601466300.events.gz', | ||
] | ||
|
||
load_dotenv(find_dotenv(".limbo-cred"), override=True) | ||
options = { | ||
"auth_version": '3', | ||
"os_username": os.environ.get('OS_USERNAME', None), | ||
"os_password": os.environ.get('OS_PASSWORD', None), | ||
"os_project_name": os.environ.get('OS_PROJECT_NAME', None), | ||
"os_auth_url": os.environ.get('OS_AUTH_URL', None), | ||
} | ||
|
||
for filename in files: | ||
# the with statement automatically closes the file at the end | ||
# of the block | ||
try: | ||
with wandio.open(filename,options=options) as fh: | ||
line_count = 0 | ||
word_count = 0 | ||
for line in fh: | ||
word_count += len(line.rstrip().split()) | ||
line_count +=1 | ||
# print the number of lines and words in file | ||
print(filename) | ||
print(line_count, word_count) | ||
except IOError as err: | ||
print(filename) | ||
raise err |
Binary file not shown.
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
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
File renamed without changes.