Read large dat file and get the necessary data
Mostrar comentarios más antiguos
I have a rather large dat file (~1.5 Gb) which I import into Matlab. It contains a text and value as below.
{
"os": [
{
"utc": "2021-09-14 02:54:56",
"lat": 35.59538,
"lon": 129.574246,
"hdt": 295.9,
"rot": -2.1,
"sog": 1.0,
"cog": 335.5,
"rudder_order_stbd": null,
"rudder_order_port": null,
"rudder_stbd": 0.0,
"rudder_port": 0.0,
"rpm_stbd": 0.0,
"rpm_port": 0.0,
"stw_long": 0.87,
"stw_trans": "NaN",
"stw_long_stern": "NaN",
"stw_trans_stern": "NaN",
"stw_speed": null,
"wind_dir": 134.0,
"wind_speed": 5.5,
"current_dir": null,
"current_speed": null
},
{
"utc": "2021-09-14 02:54:58",
"lat": 35.595385,
"lon": 129.574233,
"hdt": 295.9,
"rot": -1.3,
"sog": 0.9,
"cog": 331.1,
"rudder_order_stbd": null,
"rudder_order_port": null,
"rudder_stbd": 0.0,
"rudder_port": 0.0,
"rpm_stbd": 0.0,
"rpm_port": 0.0,
"stw_long": 0.87,
"stw_trans": "NaN",
"stw_long_stern": "NaN",
"stw_trans_stern": "NaN",
"stw_speed": null,
"wind_dir": 141.0,
"wind_speed": 5.3,
and
"ts": [
[
{
"header": "VDM",
"msg_type": 1,
"mmsi": 440196110,
"navi_status": 0,
"time_stamp": 54,
"lat": 35.515383,
"lon": 129.386093,
"hdt": 2,
"rot_raw": 0,
"rot": "0",
"cog": 327.6,
"sog": 0.0
},
{
"header": "VDM",
"msg_type": 1,
"mmsi": 355924000,
"navi_status": 0,
"time_stamp": 56,
"lat": 35.345183,
"lon": 129.467416,
"hdt": 221,
"rot_raw": -127,
"rot": "-708",
"cog": 225.0,
"sog": 2.6
}
I want to export the value for each parameter as the matrix in .DAT file. But as you can guess, for a file this size it takes forever to run through. Is there a better way of accomplishing this and export the data?
Many thanks!
2 comentarios
Stephen23
el 16 de Feb. de 2022
A representative data file can be shortened, but must include sufficient data so that we can understand the file format.
Jan
el 16 de Feb. de 2022
Yes, an 1.5 GB JSON file in text mode will take some time for reading.
It is not clear, what "export each matrix in .DAT" file means. Which matrices do you mean?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Mathematics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
