I have a log-file which lists a time and date I logged in on one website. I want to create a BarChart which compares the amount of times I did it every day. How to I make Mathematica count the amount of times, when I logged in on a certain day?
2 Answers
$\begingroup$ $\endgroup$
You could use DateHistogram for this:
logs = Import["~/Downloads/dat1.csv"]; logs = Rest[logs]; (* drop the headers *) This bit may look a bit complicated, but it's just combining the date and time strings and converting them to a DateObject, with some help about how they're formatted:
times = DateObject[{# <> " " <> #2, {"MonthShort", "DayShort", "YearShort", "Hour24", "Minute"}}] & @@@ logs; Create a histogram, with one bin for each day:
DateHistogram[times, "Day", DateTicksFormat -> {"MonthShort", "/", "Day"}] $\begingroup$ $\endgroup$
summary = Length /@ SemanticImport["C:/temp/temp.csv"][GroupBy["Date"]] BarChart[summary, ChartLabels -> Keys@Normal@summary, ImageSize -> Large] You can play with the labels as much as you wish. E.g.,
labels = DateString[#, {"MonthNameShort", "-", "Day"}] & /@ Keys@Normal@summary BarChart[summary, ChartLabels -> labels] 