Create Hive Tables From CSV Files - Cloudera Community - 204532
Maybe your like
- Community
- Training
- Partners
- Support
- Cloudera Community
- Support
- Support Questions
- Create Hive tables from CSV files
Labels:
- Apache Hadoop
- Apache Hive
Created 10-02-2017 10:51 PM
Hi All,
I have been creating Hive tables from CSV files manually copying the column names and pasting in a Hive create table script.
However I have at least 300 CSV files. I don want to repeat the same process for 300 times. Is there anyway I can autmatically create hive table creation script using the column headers as column names?
Thanks in advance
33,931 Views- All forum topics
- Previous
- Next
Created 10-03-2017 12:06 AM
@dhieru singh is your CSV file have the same format? if yes, you might consider to use
CREATE EXTERNAL TABLE table_name ( colA ... colB.. ) partitioned by .. location ... msck repair table table_name alter table table_name add partition ...every time you have a new file you just run and generate
msck repair table table_name alter table table_name add partition ... 17,486 ViewsCreated 10-03-2017 05:14 PM
@mel mendoza Thanks for the help. Unfortunately all the CSV files have different columns.
17,486 ViewsCreated on 10-03-2017 05:54 PM - edited 08-17-2019 09:59 PM
@dhieru singh,
Another way is, Use Ambari and click on HiveView as show in the below screenshot.
then click on UploadTable and if your csv file is in local then click on choose file
if you want to get column names from headers then click on the gear symbol after Filetype dropdown
The table will gets all the column names from csv file headers.
Select the database where do you want to create the table and change the table name if you want to change.
Then click on UploadTable button located at left on the screen.
17,486 ViewsCreated 10-03-2017 06:09 PM
@Shu Thanks let me try it and will update you Thanks again
17,486 ViewsCreated 04-30-2019 05:06 PM
I am facing the same issue right now. My current approach is to have a script to read the first line of all my csv files and then transform the first-line text into create sql statement.
I wonder whether this is some built-in solution from HDP.
17,486 ViewsTag » How To Add Header Column To Hive Table Csv
-
Export Hive Table Into CSV File With Header? - Spark By {Examples}
-
Hive External Table-CSV File- Header Row - Stack Overflow
-
OpenCSVSerDe For Processing CSV - Amazon Athena
-
Query Does Not Skip Header Row On External Table - Azure Databricks
-
CSV Files - Spark 3.3.0 Documentation
-
Export Hive Table Into CSV File With Header? - Pinterest
-
Hive External Table-CSV File- Header Row - Ask Codes
-
Query Does Not Skip Header Row On External Table - Knowledge Base
-
Best Way To Export Hive Table To CSV File | By Ganesh Chandrasekaran
-
How To Write CSV Data To A Table In Hive In Pyspark - ProjectPro
-
Create Hive Table From Csv - Login Page - Yonge Sushi
-
How To Export Apache Hive Data As A CSV File With Headers
-
Create Hive Tables With Headers And Load Quoted CSV Data - Hue