-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sorting summary table #2
Comments
Just to add one more thing: If I console.log the array "files" before and after the sort function, there is a difference, and the array after the sort function is in the correct order. But the csv file is always different, and there seems to be no pattern for the order. |
I think the problem is that the node.js is tricky by working asynchroniously. It probably explains why "the table is still not sorted by date in descending order. The funny thing is, that if I am starting summaryTable.bat again and agan after deleting the table, the newly generated table is always sorted in a different way". That is, in the asynchronuios mode, one should non expect that the commands are executed in the strict sequence, the command can start earlier than a command before, it's a nightmare for programmers. It is my suggestiom, and honestly, I have no idea about sorting with the node.js promises |
Just investigating further: Until this line (126) in utilities/summaryTable.js the "file" is correct:
But if I console.log "file" after this line, "file" is suddenly different. How come? |
Ended up with a very awkward "solution": At the end of summaryTable.js I added some code to open the CSV file, sort the entries and write the CSV file again. If I find the time I will probably think about a better solution ... |
if it's so, the reason is certainly because of asynchronuios features. Anyway, whatever working is better than anything not. |
In the meantime I implemented a better solution. I changed the code in summaryTable.js from approx. line 173 on so that the array is already in the desired order and table.csv is only written once. |
As mentioned already in your fitplotter repo, I am adapting your wonderful projects (fitalyser and fitplotter) to my needs. I am almost done, but one thing drives me nuts, and I hope to get some help from you.
I simply want to have the summary table sorted by date in descending order. Therefore I delete the table every time there is a new activity and changed the code in utilities/summaryTable.js as follows. The idea is to read the files in activitiesFolder and sort them by creation date in the desired order before parsing them:
But the table is still not sorted by date in descending order. The funny thing is, that if I am starting summaryTable.bat again and agan after deleting the table, the newly generated table is always sorted in a different way, which I do not understand at all.
Can you give me a hint what I am doing wrong here?
node.js and javascript is not my homeground, so maybe my question is silly, but I am always eager to learn. Thank you!
The text was updated successfully, but these errors were encountered: