Hi,
I am calling an API that downloads a .csv file. I want to calculate the numbers in a column to make sure the summary is correct. PM displays the body as text (see below). I’ve included a photo of how the .csv is actually formatted if that matters.
I’m able to verify the actually Summary value with this test below, but it feels clunky? And I can’t figure out how to reasonably calculate all values in a column. There will be times when I have maybe 50 rows of data so mapping out each individual value to be calculated would be really tedious and I’m sure there’s a better way.
pm.test("USD Sales = $35.00", function () {
var jsonData = pm.response.text();
var rows = jsonData.split('\n');
var totalRow = rows.find(row => row.includes('Summary'));
var columns = totalRow.split(',');
var usdNetSales = columns[32].trim();
pm.expect(usdNetSales).to.equal('35.00');
});
Response body:
Report: Sales by Ticket,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Group: API Test Group 1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Event: Baseline Records Event,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
"Categories: GA, Parking",,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Dates: 5/8/2023 to 11/7/2023,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Event ID,Event Name,Event Date,Pool ID,Pool Name,Sale ID,Sale Name,Venue,Initial Inventory,Starting Inventory,Ending Inventory,Max Inventory,Issued,Refunded,Canceled,Disputed,Net Issued,Sell-Through,USD Avg. Ticket Price,USD Adjusted Sales,USD Discount,USD Taxes,USD Processing Fee,USD Processing Fee to Client,USD CC Fee,USD Facility Fee,USD Service Fee,USD Handling Fee,USD Gratuity,USD Net Sales
7845,Baseline Records Event,2025-05-31,,,"107,293",Custom Form & Promo,Venue Name 1 Chicago,"1,000","1,000",999,,1,0,0,0,1,0.001,5.00,5.00,5.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,5.00
7845,Baseline Records Event,2025-05-31,,,"107,290",GA,Venue Name 1 Chicago,"1,000","1,000",999,,1,0,0,0,1,0.001,10.90,10.90,0.00,0.90,0.00,0.00,0.00,0.00,0.00,0.00,0.00,10.00
7845,Baseline Records Event,2025-05-31,,,"107,291",GA (Shipping),Venue Name 1 Chicago,"1,000","1,000",999,,1,0,0,0,1,0.001,10.90,10.90,0.00,0.90,0.00,0.00,0.00,0.00,0.00,0.00,0.00,10.00
7845,Baseline Records Event,2025-05-31,,,"107,292",Parking,Venue Name 1 Chicago,"1,000","1,000",999,,1,0,0,0,1,0.001,10.90,10.90,0.00,0.90,0.00,0.00,0.00,0.00,0.00,0.00,0.00,10.00
Summary,,,,,,,,"4,000","4,000","3,996",,4,0,0,0,4,0.001,9.43,37.70,5.00,2.70,0.00,0.00,0.00,0.00,0.00,0.00,0.00,35.00
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Generated: 11/7/2023 10:31AM PST,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Company Name v4.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Thank you!