I'm fairly new to using external data-tables. I've found a string of code that takes data from my CSV file and converts it in to data. Please note that the complete CSV file has more than 40.000 rows. For testing I only used about 12, but I couldn't get any wiser.
Now every (correct) row of this CSV-file has the first cell marked with a date (marked as 'MM/DD/YYY). There are some booger-rows in there that do not show any date, or sometimes just a string of small text -- these can obviously be ignored.
I only want to show the rows that show a certain date, and hide all other rows in this column.
or to be more specific; I only want to show the rows that have the date of 365 days before today.
HTML:
<table>
<th> Date
</th>
<th> Time
</th>
<th> Message
</th>
</table>
JS: - with this code my large CSV file gets converted to a HTML table.
<script src="http://d3js.org/d3.v3.min.js"></script>
<!-- <script src="d3.min.js?v=3.2.8"></script> -->
<script type="text/javascript" charset="utf-8">
d3.text("data.csv", function(data) {
var parsedCSV = d3.csv.parseRows(data);
var container = d3.select("body")
.append("table")
.selectAll("tr")
.data(parsedCSV).enter()
.append("tr")
.selectAll("td")
.data(function(d) {
return d;
}).enter()
.append("td")
.text(function(d) {
return d;
});
});
Solution: a plain Javascript filter. Since the CSV rows are converted to a HTML table, a filter would do fine.
I have yet to find out how to make the filter a default input, or how to make it dynamic based on the month and day.