在猪中读取csv,csv文件包含带引号的逗号 [英] csv reading in pig, csv file contains quoted comma
本文介绍了在猪中读取csv,csv文件包含带引号的逗号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我的数据看起来像这样
So my data looks something like this
asdf, asdf, "adsf,qwef", asdf
当我使用 Pig 读取数据时
When i read that data in pig using
PigStorage(',')
它将adsf,qwef"存储为两个数据,并像这样存储
It stores the "adsf,qwef" as a two data, and stores it like
{ "adsf } { qwef" }
我希望将引号视为单个数据.
I want quotes to be treated as single data.
我该怎么办?
我正在尝试编写一个pigscript来做到这一点.
推荐答案
您应该使用 CSVLoader:
You should use the CSVLoader:
data = LOAD 'my.csv' USING org.apache.pig.piggybank.storage.CSVExcelStorage()
AS (...);
其中 ... 是标识符.
Where the ... is the identifiers.
注意:您必须先注册 Piggybank.详情请见:https://cwiki.apache.org/confluence/display/PIG/PiggyBank
NOTE: You'll have to register the Piggybank first. Details here: https://cwiki.apache.org/confluence/display/PIG/PiggyBank
这篇关于在猪中读取csv,csv文件包含带引号的逗号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文