将非结构化数据处理为结构化数据以建立预测模型



我是Hadoop的新手,我有非结构化数据文件,需要转换为结构化数据,这在mapreduce中可能吗?如果不是,哪种是最佳做法

file1.txt

Message-ID: <5482922.1075855813971.JavaMail.evans@thyme>
Date: Thu, 26 Oct 2000 09:21:00 -0700 (PDT)
From: ted.bland@enron.com
To: janet.dietrich@enron.com, wes.colwell@enron.com, sally.beck@enron.com, 
    kevin.presto@enron.com, thomas.martin@enron.com, 
    hunter.shively@enron.com, scott.neal@enron.com, w.duran@enron.com, 
    jeff.donahue@enron.com, brian.redmond@enron.com
Subject: Super Saturday Interviewers for October 28, 2000

file2.txt
Message-ID: <12142333.1075855814153.JavaMail.evans@thyme>
Date: Tue, 24 Oct 2000 14:12:00 -0700 (PDT)
From: enron.announcements@enron.com
To: ena.employees@enron.com
Subject: Associate/Analyst Super Saturday Participation - ADDITIONAL REQUEST

file1.txt and file2.txt are two file, i want the output like
Message-ID      Date        From        To      Subject
respective values as like table. Is that possible in Mapreduce?

Hadoop API提供了一个InputFormat接口,用于定义如何将输入数据转换为键-值对的集合。

已经有许多内置的输入格式(请参阅文档中实现类的列表),但它们是非常通用的,更适合结构化数据。例如,TextInputFormat假设每一行都是一个单独的记录,并生成键值对,其中键是行号,值是文本行。

对于非结构化数据,您必须定义自己的自定义输入格式类。这里有一个关于如何做到这一点的简短教程的链接。

顺便说一句,考虑使用ApacheSpark,它拥有Hadoop所能提供的一切,也是一个非常有用的机器学习库,可以用来构建模型。

最新更新