问题描述
一直在尝试编写一个函数,该函数从 numpy 数组中接收通道数据并将它们写入 ORC 文件。为此,我一直在使用 PyORC python 库。但是,我发现有效写入文件的唯一方法是使用 for 循环。 numpy 数组有很多成员,我正试图减少我的 ORC 文件生成的处理时间和文件大小......据我所知,这是一种非常低效的方法。
我尝试使用 Pandas 根据我在网上找到的一些代码创建数据帧,但是即使使用相同版本的 pyorc 和 Pandas,此代码也拒绝执行。
我目前的实现是这样的:
def writeORC(CH1,CH2,lenth):
"""Writes into stripes within the ORC format (See: https://pyorc.readthedocs.io/en/latest/tutorial.html#stripes and https://cwiki.apache.org/confluence/display/hive/languagemanual+orc)
writer object Explicitly specifies the structure each row of our columns of orc data. The schema can be a TypeDescription or a simple string ORC schema deFinition.
The current implementation uses a for loop to populate each row,It is important to note that the close() method is essential for the validity of the file.
"""
start_time = process_time()
output = open("./new.orc","wb")
writer = pyorc.Writer(output,"struct<col0:float,col1:float>") # col0,col1 are changable names
for i in range(lenth):
writer.write((CH1[i],CH2[i]))
print("file written \n")
writer.close()
stop_time = process_time()
print("writeORC took " + " %s seconds to execute " % (stop_time-start_time))
print("The file generated is " + str(os.path.getsize("new.orc") / 1000 ) + " Kilobytes \n")
请帮忙。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)