在猪中读取 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