Ramesh Rajanala
Ramesh Rajanala

Reputation: 21

How to fetch records count from Azure data lake analytics files (File like txt and CSV )

adl://rs06ipadl01.azuredatalakestore.net/FIA/RDS/old/BANNER/2018/06/15/old_Banner.csv

i need to fetch the records from above file.

Upvotes: 2

Views: 621

Answers (1)

wBob
wBob

Reputation: 14379

You can the built-in extractors like .Csv and .Text to get the file content then use COUNT to count the records. A simple example:

DECLARE @inputFile string = @"input/input124.csv";
DECLARE @outputFile string = @"output/output.csv";

// Get the file
@input =
    EXTRACT col1 string,
            col2 string,
            col3 int
    FROM @inputFile
    USING Extractors.Csv( skipFirstNRows:1 );     // skip header row if you have one


// Count the records
@output = SELECT COUNT(*) AS records FROM @input;


// Output the result
OUTPUT @output
TO @outputFile
USING Outputters.Csv(quoting:false);

Upvotes: 2

Related Questions