小编Bry*_*ice的帖子

如何将二进制转换为数据?

我一直在尝试转换从R中的API获得的二进制数据,但是它没有正确解析和转换值。

这是二进制文件的示例:

00 00 00 01 00 04 53 42 55 58 00 00 00 25 c8 42 9b cc cd 42 9c 8a 3d 42 9b b8 52 42 9c 23 d7 44 bd 5e 14 00 00 01 43 53 5c 62 40
Run Code Online (Sandbox Code Playgroud)

结果应为:

SBUX    77.9    78.27   77.86   78.07   1153261076  1/2/2014 9:30
Run Code Online (Sandbox Code Playgroud)

带有正确数据类型和大小的示例代码

readBin(file2read[1:4],integer(),n=1, size=4) #Symbol Count
readBin(file2read[5:6],integer(),n=1,size=2) #Symbol length
readBin(file2read[7:10],character(),n=4) #Sympbol = SBUX
readBin(file2read[11],integer(),n=1,size=1) #Error code
readBin(file2read[12:15],integer(),n=4) #Bar Count
readBin(file2read[16:19],double(),n=4,size=4) #close
readBin(file2read[20:23],double(),n=1,size=4) #high
readBin(file2read[24:27],double(),n=1,size=4) #low …
Run Code Online (Sandbox Code Playgroud)

import r binary-data

5
推荐指数
1
解决办法
1509
查看次数

标签 统计

binary-data ×1

import ×1

r ×1