Hadoop/Hive : Loading data from .csv on a local machine

后端 未结 6 1375
不知归路
不知归路 2020-12-24 05:20

As this is coming from a newbie...

I had Hadoop and Hive set up for me, so I can run Hive queries on my computer accessing data on AWS cluster. Can I run Hive querie

6条回答
  •  自闭症患者
    2020-12-24 06:11

    Let me work you through the following simple steps:

    Steps:

    First, create a table on hive using the field names in your csv file. Lets say for example, your csv file contains three fields (id, name, salary) and you want to create a table in hive called "staff". Use the below code to create the table in hive.

    hive> CREATE TABLE Staff (id int, name string, salary double) row format delimited fields terminated by ',';
    

    Second, now that your table is created in hive, let us load the data in your csv file to the "staff" table on hive.

    hive>  LOAD DATA LOCAL INPATH '/home/yourcsvfile.csv' OVERWRITE INTO TABLE Staff;
    

    Lastly, display the contents of your "Staff" table on hive to check if the data were successfully loaded

    hive> SELECT * FROM Staff;
    

    Thanks.

提交回复
热议问题