So far every resource I have seen on loading CSV files into D3.js require that the only way to use the data is to define callback functions (due to Javascript's asynchronous execution).
I originally approached this problem the usual way of defining functions outside then calling them inside the callback function. However this proved repetitive. The other alternative however, to define everything in the callback function, would lead to repeated executions of the same thing leading to redundancy.
I personally found that if I knew how many data items were going to be used, I could simply set an
if (read_data_length==total_data_length)
condition so that all my code is executed once every CSV row is read.
My question is whether there is a way to identify the length of a CSV file (in terms of number of Objects, or rows), BEFORE loading a CSV file in order to establish such a limit?
So far my own insight has proven this is difficult to impossible, but I am hoping somebody with more experience in Javascript might be able to clear this up. Thanks in advance.