Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8664609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:16:53+00:00 2026-06-12T17:16:53+00:00

How do you process a flat file with Pig? For example, if you had

  • 0

How do you process a flat file with Pig? For example, if you had a line containing a record where the first four positions were the year, the next 5 were a product code, and the last 8 contained the MSRP, how would you query this data with Pig? I’m probably missing something simple, but everything I’ve found thus far requires a delimiter to be used when loading data with Pig.

Some sample data is provided below:

1999ABCDE12234.00
2000DCEFS00020.00
2012FFEWS00005.55

Thanks in advance.

Jeremy

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:16:54+00:00Added an answer on June 12, 2026 at 5:16 pm

    One way to split a line based on positions is to use REGEX_EXTRACT_ALL .

    E.g:

    A = LOAD 'flat.txt' as (line:chararray);
    B = FOREACH A GENERATE FLATTEN(REGEX_EXTRACT_ALL(line, 
          '^(.{1,4})(.{1,5})(.*)$')) AS (year:int, prod_code:chararray, msrp:double);
    dump B;
    (1999,ABCDE,12234.00)
    (2000,DCEFS,00020.00)
    (2012,FFEWS,00005.55)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am supporting an ETL process that transforms flat-file inputs into a SqlServer database
Here's the scenario: Process 1 (P1) - reads in various flat files one consequence
Current Process: I have a tar.gz file. (Actually, I have about 2000 of them,
I have to read in a large record set, process it, then write it
I have a flat data file that I need to import into my SQL
A third party is sending us a flat file that is supposed to contain
I have a flat file database (yeah gross I know - the worst part
Short Question: Is there any nosql flat-file database available as sqlite? Explanation: Flat file
The problem : I have multiple parallel processes that handle flat file records .
I'm looking for the file name containing the implementation of the Proceed to Checkout

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.