I came across this particular method for accessing a local text file.
However, I am facing an issue as I do not want the file to be read asynchronously. My goal is to have the function read the file and return the output as a string variable instead.
The format of my file is as follows:
time acceleration velocity position
0 0 0 0
0.1 0.7584280404 0.075842804 0.0075842804
0.2 0.1291023633 0.0887530404 0.0164595844
0.3 0.4040327317 0.1291563135 0.0293752158
0.4 0.8891570587 0.2180720194 0.0511824177
0.5 0.3481323377 0.2528852532 0.0764709431
0.6 0.8920292137 0.3420881745 0.1106797605
0.7 0.7375283292 0.4158410075 0.1522638613
0.8 0.2647998196 0.4423209894 0.1964959602
0.9 0.633358462 0.5056568356 0.2470616438
1 0.3901214569 0.5446689813 0.3015285419
1.1 0.4712272086 0.5917917022 0.3607077121
1.2 0.693854515 0.6611771537 0.4268254275
1.3 0.4248616176 0.7036633154 0.497191759
The extracted data will be stored in obj
with the following fields:
obj.time
obj.acceleration
obj.velocity
obj.position
These values need to be retrieved from the first row of the text file. All operations are conducted locally, so the loading time of heavy js
libraries is not a concern. If anyone knows of a shortcut that meets my requirements, please share it. Alternatively, if there is no existing library, guidance on how to read a file synchronously would also be appreciated.