我想将txt文件中的数据重新组织到Python中,但这是我第一次尝试,我很难弄清楚该怎么做。我想有一个DataFrame,其输出提取如下。该文件看起来像下面的摘录,但是此摘录以不同的编号重复其自身。因此,DataFrame示例中的索引列(第一个提取的索引为1,第二个索引为2,依此类推...)。请注意,我只需要文件中的3个字段:出价/要求,[]之间的第一个和第二个数据。我认为最好在Pandas下进行,但是请随时对此发表评论。
文件:
{"offset":"14726172634","bids":
[["871094.22000","0.00200000","0.00200000","0","1081537351","29194","5","14726172633","1"],
...
["0.00050","835520.00000000","835520.00000000","0","391768510","545540","5","12603499158","0"]],"asks":[["876256.20000","0.00500000","0.00500000","0","1081621054","29194","5","14726396226","1"],
...
["9999999.00000","0.01000000","0.01000000","0","568775590","75620","5","12301971393","1"]]}
输出:
index side P Q
1 bids 871094.22000 0.00200000
...
bids 0.00050 835520.00000000
1 asks 876256.200000 0.00500000
...
asks 9999999.00000 0.01000000