Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ os:
- linux
julia:
- 1.0
- 1.1
- 1.2
- 1.3
- nightly
notifications:
email: false
Expand Down
22 changes: 22 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name = "LogParser"
uuid = "e1e0bead-d0c8-5de7-863f-c4b0e859faac"
version = "0.7.0"


[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"

[compat]
CSV = "~0.5.0"
DataFrames = "~0.20"
GZip = "~0.5.0"
julia = "1.0"

[extras]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
GZip = "92fee26a-97fe-5a0c-ad85-20a5f3185b63"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["CSV", "Test", "DataFrames", "GZip"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The API for this package is straightforward:
logarray = [...] #Any AbstractArray of Strings

#Parse file
parsed_vals = parseapachecombined(logarray)
parsed_vals = parseapachecombined.(logarray)

#Convert to DataFrame if desired
parsed_df = DataFrame(parsed_vals)
Expand Down
2 changes: 0 additions & 2 deletions REQUIRE

This file was deleted.

7 changes: 2 additions & 5 deletions src/LogParser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const apachecombinedregex = r"""([\d\.]+) ([\w.-]+) ([\w.-]+) (\[.+\]) "([^"\r\n
#
###############################################################################

function parseapachecombined(logline::AbstractString)
function parseapachecombined(logline::T) where T <: AbstractString

regexarray = [apachecombinedregex, firstsevenregex, firstsixregex, firstfiveregex, firstfourregex, firstthreeregex, firsttworegex, firstfieldregex]

Expand Down Expand Up @@ -98,9 +98,6 @@ function parseapachecombined(logline::AbstractString)

end #End parseapachecombined::String

parseapachecombined(logarray::Array) = ApacheLog[parseapachecombined(x) for x in logarray]


###############################################################################
#
#
Expand Down Expand Up @@ -134,7 +131,7 @@ function DataFrame(logarray::Array{ApacheLog,1})
_df = DataFrame()

for value in sym
_df[value] = eval(value)
_df[!, value] = eval(value)
end

return _df
Expand Down
6 changes: 3 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ using LogParser, Test, GZip, CSV, DataFrames

#Read in gzipped file
gzipfile = gzopen(joinpath(dirname(@__FILE__), "data", "juliabloggers-apachecombined.gz"))
jbapachecombined = CSV.read(gzipfile, delim='\t', datarow=1)
jbapachecombined = CSV.read(gzipfile, delim='\t', datarow=1) |> DataFrame

#Parse file
jbparsed = parseapachecombined(jbapachecombined[:Column1])
jbparsed = parseapachecombined.(jbapachecombined[!, :Column1])

#Test that array is 122,143 elements long
@test size(jbparsed)[1] == 122143

#Test that array is of type Array{ApacheLog,1}
@test typeof(jbparsed) == Array{ApacheLog,1}
@test typeof(jbparsed) == Vector{ApacheLog}

#Test DataFrame method
jbparsed_df = DataFrame(jbparsed)
Expand Down