简体   繁体   English

如何将Windows OS的文件复制到cloudera? 我也想将.csv文件导入到配置单元中,我该怎么做?

[英]How to copy a file fron windows os to cloudera ? I also want to import the .csv file in to the hive, how can i do that?

How to copy a file from windows OS to cloudera ? 如何将文件从Windows操作系统复制到cloudera? I also want to import the .csv file in to the hive, how can i do that ? 我也想将.csv文件导入到配置单元中,我该怎么做? Please help me to get it done. 请帮助我完成它。

To get the file into Linux you will need to either ftp it to the CentOS CLoudera box or mount a file share and copy it from there. 为了使文件进入Linux,您需要将其通过ftp下载到CentOS CLoudera盒中,或者挂载文件共享并从那里复制它。

Once on the CentOS/Cloudera box you can open the web browser and log into Cloudera Manager and Hue which is the user interface to Hive/Pig etc. There are icons across the top with the third from the left being Beeswax/Hive. 一旦进入CentOS / Cloudera框,您就可以打开Web浏览器并登录到Cloudera Manager和Hue,这是Hive / Pig等的用户界面。顶部有图标,左边第三个是Beeswax / Hive。 Click on that icon and start from there. 单击该图标,然后从那里开始。

Your other choice once you have the file on the Cloudera box is to use the Hadoop fs commands found HERE specifically copyFromLocal 将文件放在Cloudera框中后,您的另一选择是使用在此处找到的Hadoop fs命令,特别是copyFromLocal

To load your file into Hive you can do one of two things. 要将文件加载到Hive中,您可以执行以下两项操作之一。 Load it into a single large staging field and then parse it into fields you want using offsets like so: 将其加载到单个大的暂存字段中,然后使用偏移量将其解析为所需的字段,如下所示:

LOAD DATA INPATH '/user/xyz/Inbound/files/target.csv' INTO TABLE 'myTable'

This loads the entire record into a single field. 这会将整个记录加载到一个字段中。 Then you would do the following once loaded. 然后,您将在加载后执行以下操作。

INSERT OVERWRITE TABLE myTable SELECT
regexp_extract(col_value, '^(?:([^,]*)\,?)(1)', 1) New_Field_name1
regexp_extract(col_value, '^(?:([^,]*)\,?)(5)', 1) New_Field_name2
......
FROM myTable;

The syntax looks challenging but it is not bad, you will just have to read up on HiveQL Hue also allows you to load a CSV into the individual fields but you have to add the field names yourself. 语法看起来很有挑战性,但还不错,您只需要阅读HiveQL Hue,还可以将CSV加载到各个字段中,但是您必须自己添加字段名称。 I have never done that before though. 我从来没有做过。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM