如何将本地ORC文件转换为CSV? [英] How can I convert local ORC files to CSV?

查看:703
本文介绍了如何将本地ORC文件转换为CSV?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的本​​地计算机上有一个ORC文件,并且需要任何合理的格式(例如CSV,JSON,YAML等)。

I have an ORC file on my local machine and I need any reasonable format from it (e.g. CSV, JSON, YAML, ...).

如何我将ORC转换为CSV吗?

How can I convert ORC to CSV?

推荐答案


  1. 下载

  2. 提取文件,然后转到 java 文件夹并执行maven: mvn install

  3. 使用ORC工具

  1. Download
  2. Extract the files, go to the java folder and execute maven: mvn install
  3. Use ORC-Tools

这就是我的用法-您可能需要调整路径:

This is how I use them - you will likely need to adjust the paths:

java -jar ~/.m2/repository/org/apache/orc/orc-tools/1.5.4/orc-tools-1.5.4-uber.jar data ~/your_file.orc > output.json

输出为 JSON行,可轻松转换为CSV。首先,我需要从输出中删除最后两行。然后:

The output is JSON Lines which is easy to convert to CSV. First I needed to remove the last two lines from the output. Then:

import pandas as pd

df = pd.read_json('output.json', lines=True)
df.to_csv('output.csv')

这篇关于如何将本地ORC文件转换为CSV?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆