hive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sarath <sarathchandra.jos...@algofusiontech.com>
Subject Re: Problem loading a CSV file
Date Fri, 28 Sep 2012 10:02:45 GMT
Thanks Miao and Savant for your responses.

My file is already in HDFS but still I'm facing the error. Infact I 
could browse to this file with the same path and see it's contents using 
the web interface of HDFS. So I don't think it's issue with path.

Did some trial and error and now it is working. Here's what I did -
-> Converted the CSV file into a plain text file and replaced all "," 
(commas) with ";" (semi-colons)
-> Used the same create query with external option as given in my 
earlier mail. But this time removed the row format specification.

create external table table1 (field1 STRING, field2 STRING, field3 STRING,
field3 STRING, field4 STRING, field5 FLOAT, field6 FLOAT, field7 FLOAT,
field8 STRING, field9 STRING) location '/user/hduser/dumps/table_dump.txt';


Now I'm able to query, get the row count and do all other operations on 
this table.
So looks like I'm not using the right way to load the CSV files.

Can anyone throw some light here?

Regards,
Sarath.

On Friday 28 September 2012 03:14 PM, MiaoMiao wrote:
> When creating external table with location clause, you need to put
> your csv into HDFS.
> Or else you can load data local as Savant said.
>
> On Fri, Sep 28, 2012 at 1:57 PM, Sarath
> <sarathchandra.josyam@algofusiontech.com> wrote:
>> Hi,
>>
>> I have created a new table using reference to a file on HDFS -
>> create external table table1 (field1 STRING, field2 STRING, field3 STRING,
>> field3 STRING, field4 STRING, field5 FLOAT, field6 FLOAT, field7 FLOAT,
>> field8 STRING, field9 STRING) row format delimited fields terminated by ','
>> location '/user/hduser/dumps/table_dump.csv';
>>
>> The table got created successfully. But when I try retrieving rows from this
>> table, it returns me nothing.
>> hive> select * from table1;
>> OK
>> Time taken: 0.156 seconds
>>
>> I also tried creating the table first and then loading the HDFS file data
>> into it -
>> hive> create table table1 (field1 STRING, field2 STRING, field3 STRING,
>> field3 STRING, field4 STRING, field5 FLOAT, field6 FLOAT, field7 FLOAT,
>> field8 STRING, field9 STRING) row format delimited fields terminated by ',';
>> OK
>> Time taken: 0.088 seconds
>>
>> But when I try to load data into this table I'm getting below error -
>> hive> load data inpath '/user/hduser/dumps/table_dump.csv' overwrite into
>> table table1;
>> FAILED: Error in semantic analysis: Line 1:17 Invalid path
>> ''/user/hduser/dumps/table_dump.csv'': No files matching path
>> hdfs://master:54310/user/hduser/dumps/table_dump.csv
>>
>> What is going wrong? Is there a different way to load a CSV file using hive?
>>
>> Regards,
>> Sarath.

Mime
View raw message