Here is the solution -
data = load 'sample.csv' as (number:chararray);
b = FOREACH data GENERATE (LONG) REPLACE(number, ' ', '');
I have used the inbuilt filter function REPLACE to get the desired output -
chararray REPLACE(chararray source, chararray toReplace, chararray newValue) Parameters: source: the chararray to search in toReplace: the chararray to be replaced newValue: the new chararray to replace it with Returns: source with all instances of toReplace changed to newValue
Hope this helps