我正在尝试将我的数据从JSON文件加载到用,
分隔的MATLAB中。
我的数据格式如下:
{"created_at": "Mon Oct 27 20:35:47 +0000 2014", "tweet": "Silver Finished Up, Gold, Copper, Crude Oil, Nat Gas Down - Live Trading News http://t.co/jNLTUIgHwA", "id": 526834668759285761, "sentiment": "negative"}
{"created_at": "Mon Oct 27 20:36:21 +0000 2014", "tweet": "Gold, Silver slips on lacklustre demand- The Economic Times http://t.co/Jd5Tn9ctfX", "id": 526834810300289024, "sentiment": "negative"}
我该怎么做?
答案 0 :(得分:2)
从版本2016b开始,Matlab已经集成了json支持。
请参阅: 的 https://www.mathworks.com/help/matlab/ref/jsondecode.html 强>
简而言之,您可以:
nextFilter
答案 1 :(得分:0)
阅读一行:
tweet_info = loadjson('~/Desktop/test.json')
这是存储在tweet_info {1}
中的内容 created_at: 'Mon Oct 27 20:35:47 +0000 2014'
tweet: 'Silver Finished Up, Gold, Copper, Crude Oil, Nat Gas Down - Live Trading News http://t.co/jNLTUIgHwA'
id: 5.2683e+17
sentiment: 'negative'
这是存储在test.json文件中的内容
{“created_at”:“Mon Oct 27 20:35:47 +0000 2014”,“推特”:“白银成品,黄金,铜,原油,天然气下跌 - 实时交易新闻http://t.co/jNLTUIgHwA “,”“id”:526834668759285761,“情绪”:“否定”}
{“created_at”:“Mon Oct 27 20:36:21 +0000 2014”,“推特”:“黄金,白银因需求低迷而滑倒 - 经济时报http://t.co/Jd5Tn9ctfX”,“id”:526834810300289024 ,“情绪”:“消极”}