How can we ignore header line while loading data into Pig?

0 votes

I have a text file which has header line + data lines.

Suppose we have a dataset like below,

"id","name","sal"
"1","jimmy","1000"
"2","hendrix","5000" 

How can we ignore header line while loading data into Pig?

Jul 10 in Big Data Hadoop by Ritu
41 views

1 answer to this question.

0 votes

Suppose you need to load this in an alias in pig but don't want the header. So, we can execute the below set of commands to remove the header.

A = load 'pigtest.txt' using PigStorage(',') as (id: chararray, name: chararray, sal: chararray);
ranked = rank A;
no_header = filter ranked by (rank_A > 1);
ordered = order no_header by rank_A;
new_A = foreach ordered generate id, name, sal;

Now, let's dump the new data,

dump new_A;
answered Jul 10 by Kiran

Related Questions In Big Data Hadoop

0 votes
1 answer

How can we send data from MongoDB to Hadoop?

The MongoDB Connector for Hadoop reads data ...READ MORE

answered Mar 26, 2018 in Big Data Hadoop by nitinrawat895
• 10,670 points
111 views
+3 votes
1 answer

Getting Connection Error while loading data into table using cloudera hive

Hey Nafeesa, Itseems that Hive is not able ...READ MORE

answered Oct 3, 2018 in Big Data Hadoop by Vardhan
• 12,470 points
70 views
0 votes
1 answer

Hadoop Hive: How to skip the first line of csv while loading in hive table?

You can try this: CREATE TABLE temp ...READ MORE

answered Nov 8, 2018 in Big Data Hadoop by Omkar
• 67,380 points
825 views
0 votes
1 answer

Getting error while loading data into hive table

In the command you have used, the ...READ MORE

answered Jan 30 in Big Data Hadoop by Omkar
• 67,380 points
187 views
0 votes
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,670 points
2,679 views
0 votes
1 answer

hadoop.mapred vs hadoop.mapreduce?

org.apache.hadoop.mapred is the Old API  org.apache.hadoop.mapreduce is the ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,670 points
279 views
0 votes
10 answers

hadoop fs -put command?

put syntax: put <localSrc> <dest> copy syntax: copyFr ...READ MORE

answered Dec 7, 2018 in Big Data Hadoop by Aditya
13,297 views
0 votes
1 answer

Hadoop dfs -ls command?

In your case there is no difference ...READ MORE

answered Mar 16, 2018 in Big Data Hadoop by kurt_cobain
• 9,240 points
978 views
0 votes
1 answer

How can we ignore header line while loading data into Pig?

You can use the following code: A = ...READ MORE

answered Jul 22 in Big Data Hadoop by kiran
12 views
0 votes
1 answer

How to load data from HDFS into pig relation?

Hey, To load data from HDFS to pig ...READ MORE

answered May 7 in Big Data Hadoop by Gitika
• 25,340 points
35 views