Last active
October 14, 2016 10:48
-
-
Save vchuravy/79cc3164d9109f9237d5 to your computer and use it in GitHub Desktop.
Pipe ls -l into DataFrame
This file contains hidden or 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
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