Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
U-SQL doesn't support constructs to generate Unique Identifier in Text Files. The script below generates unique identifier for every row in the input file.
The steps are
REFERENCE ASSEMBLY [ExtPython];
DECLARE @ReduceScript = @" import uuid import base64
def usqlml_main(df): df['sguid'] = '' df['sguid'] = df.sguid.apply(lambda row: str(base64.urlsafe_b64encode(uuid.uuid1().bytes))) return df ";
@AllData = EXTRACT OrderNo string, Date string, CustomerCode string, ProductCode string, SalesArea string, OrderValue string FROM "/DataLoads/Input/TempFile.csv" USING Extractors.Text(delimiter: ',', skipFirstNRows: 1);
@ReducedData = REDUCE @AllData ON CustomerCode PRODUCE sguid string, OrderNo string, Date string, CustomerCode string, ProductCode string, SalesArea string, OrderValue string USING new Extension.Python.Reducer(pyScript:@ReduceScript);
OUTPUT @ReducedData TO "/DataLoads/CSVOutputwithGUID.txt" USING Outputters.Text(); |
Note : Follow these instructions to enable U-SQL extensions on your ADL-A account
Please sign in to use this experience.
Sign in