Coder Social home page Coder Social logo

Sorting summary table about fitalyser HOT 6 CLOSED

rucksman avatar rucksman commented on August 24, 2024
Sorting summary table

from fitalyser.

Comments (6)

rucksman avatar rucksman commented on August 24, 2024

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.

from fitalyser.

karaul avatar karaul commented on August 24, 2024

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

https://wanago.io/2018/04/09/explaining-promises-and-callbacks-while-implementing-a-sorting-algorithm/

from fitalyser.

rucksman avatar rucksman commented on August 24, 2024

Just investigating further: Until this line (126) in utilities/summaryTable.js the "file" is correct:

fs.readFile(activitiesFolder + "/" + file, function (err, content) {

But if I console.log "file" after this line, "file" is suddenly different. How come?

from fitalyser.

rucksman avatar rucksman commented on August 24, 2024

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 ...

from fitalyser.

karaul avatar karaul commented on August 24, 2024

s I added some code to open the CSV file, sort the entries and write the CSV file again

if it's so, the reason is certainly because of asynchronuios features. Anyway, whatever working is better than anything not.

from fitalyser.

rucksman avatar rucksman commented on August 24, 2024

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.

from fitalyser.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.