-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removing dateutil import inside function, adding test that uses dateu…
…til.parser.parse, and added dateutil as a dev dependency
- Loading branch information
1 parent
628c547
commit d28aa41
Showing
4 changed files
with
30 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,27 @@ | ||
import csv | ||
import os | ||
from datetime import datetime | ||
|
||
from dateutil.parser import parse as date_parse | ||
|
||
from traces import TimeSeries | ||
|
||
|
||
def test_csv(): | ||
filename = "sample.csv" | ||
with open(filename, "w") as csvfile: | ||
writer = csv.writer(csvfile) | ||
writer.writerow(["hour", "value"]) | ||
writer.writerow(["2000-01-01 10:00am", "15"]) | ||
writer.writerow(["2000-01-01 11:00am", "34"]) | ||
writer.writerow(["2000-01-01 12:00pm", "19"]) | ||
writer.writerow(["2000-01-01 1:00pm", "nan"]) | ||
writer.writerow(["2000-01-01 2:00pm", "18"]) | ||
writer.writerow(["2000-01-01 3:00pm", "nan"]) | ||
|
||
ts = TimeSeries.from_csv(filename, time_transform=date_parse) | ||
os.remove(filename) | ||
|
||
assert ts[datetime(2000, 1, 1, 9)] is None | ||
assert ts[datetime(2000, 1, 1, 10, 30)] == "15" | ||
assert ts[datetime(2000, 1, 1, 20)] == "nan" |
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