Skip to content

Commit ca19058

Browse files
author
Shashi Gowda
committed
treat datetime that fails to parse as string
1 parent fc46d3f commit ca19058

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/guesstype.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ function guessdateformat(str)
2525
dts = vcat(dts, Any[DateTime => d for d in common_datetime_formats])
2626

2727
for (typ, df) in dts
28-
x, len = tryparsenext_internal(typ, str, 1, endof(str), df)
28+
x, len = try
29+
tryparsenext_internal(typ, str, 1, endof(str), df)
30+
catch err
31+
continue
32+
end
2933
if !isnull(x)
3034
try
3135
typ(get(x)...)

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ import TextParse: _csvread
425425
time,value
426426
"2017-11-09T07:00:07.391101180",0
427427
"""
428+
@test _csvread(s) == ((String["2017-11-09T07:00:07.391101180"], [0]), String["time", "value"])
428429
@test _csvread(s, colparsers=Dict(:time=>String)) == ((String["2017-11-09T07:00:07.391101180"], [0]), String["time", "value"])
429430
end
430431

0 commit comments

Comments
 (0)