Skip to content

Instantly share code, notes, and snippets.

@vchuravy
Last active October 14, 2016 10:48
Show Gist options
  • Save vchuravy/79cc3164d9109f9237d5 to your computer and use it in GitHub Desktop.
Save vchuravy/79cc3164d9109f9237d5 to your computer and use it in GitHub Desktop.
Pipe ls -l into DataFrame
using DataFrames
using Dates # I am on 0.3
# Note the quoting style and the custom time-style
# sed is used to remove softlinks "dir" -> "../dir"
cmd = `ls -1 -l --quoting-style=c --time-style='+%Y-%m-%d_%H:%M'` |> `sed 's/ -> ".*"$//g'`
df = open(cmd, "r", STDOUT) do io
readtable(io, header=false,
separator=' ',
names = [:Permissions, :Links, :Owner, :Group, :Size, :TimeRaw, :Name],
skipstart=1
)
end
# A bit of post-processing
df[:Time] = map(df[:TimeRaw]) do date
DateTime(date, "+y-m-d_H:M")
end
delete!(df, :TimeRaw)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment