flink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Metzger <rmetz...@apache.org>
Subject Re: want write Specified field from dataset to output file
Date Tue, 12 May 2015 07:41:33 GMT
Hi,

please have a look at the programming guide on how to write results to an
output file:
http://ci.apache.org/projects/flink/flink-docs-master/apis/programming_guide.html#data-sinks

In your case, I would recommend:

customers.writeAsFormattedText("file:///path/to/the/result/file",
    new TextFormatter<Customer3>>() {
        public String format (Customer3 value) {
            return value.getField(2).toString();
        }
    });



On Tue, May 12, 2015 at 9:20 AM, hagersaleh <loveallah1987@yahoo.com> wrote:

> I want write Specified field from dataset to output file
> I want write field 2 to output file
> example
> DataSet<Customer3>
> customers=env.readCsvFile("/home/hadoop/Desktop/Dataset/customer.csv")
>                     .fieldDelimiter('|')
>                     .includeFields(11000010).ignoreFirstLine()
>                     .tupleType(Customer3.class);
>                     customers = customers.filter(new
> FilterFunction<Customer3>()
>                         {
>                             @Override
>                             public boolean filter(Customer3 c) {
>
>
>                             c.getField(2).toString().equals("AUTOMOBILE");
>                            }
>                       return true;
>
>                         }
>                 });
>                customers.print();
>
> customers.writeAsCsv("/home/hadoop/Desktop/Dataset/out2.csv", "\n", "|");
>                }
>
>
>
>
> --
> View this message in context:
> http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/want-write-Specified-field-from-dataset-to-output-file-tp1223.html
> Sent from the Apache Flink User Mailing List archive. mailing list archive
> at Nabble.com.
>

Mime
View raw message