WRLD
WRLD
CC#
Created by WRLD on 6/28/2024 in #help
✅ Reading .csv files correctly
hey im trying to read a .csv file correctly by sorting the different values etc insied of it, two of those values are revenue and price and im trying to add all that up into my varible but i ends up as 0 all the time does anyone know what im doing wrong the format of the csv file is like this: "Id,Buyer User Id,Date and Time,Location,Location Id,Universe Id,Universe,Asset Id,Asset Name,Asset Type,Hold Status,Revenue,Price"
C#
string[] values = line.Split(',');
if (values.Length >= 14)
{
string holdStatus = values[10];
decimal revenue = 0;
decimal price = 0;
if (decimal.TryParse(values[11], out revenue) && decimal.TryParse(values[12], out price))
{
if (holdStatus.Equals("Released", StringComparison.OrdinalIgnoreCase))
{
totalEarnedReleased += revenue;
totalSpentReleased += price;
releasedCount++;
}
else if (holdStatus.Equals("Held", StringComparison.OrdinalIgnoreCase))
{
totalEarnedHeld += revenue;
totalSpentHeld += price;
heldCount++;
}
C#
string[] values = line.Split(',');
if (values.Length >= 14)
{
string holdStatus = values[10];
decimal revenue = 0;
decimal price = 0;
if (decimal.TryParse(values[11], out revenue) && decimal.TryParse(values[12], out price))
{
if (holdStatus.Equals("Released", StringComparison.OrdinalIgnoreCase))
{
totalEarnedReleased += revenue;
totalSpentReleased += price;
releasedCount++;
}
else if (holdStatus.Equals("Held", StringComparison.OrdinalIgnoreCase))
{
totalEarnedHeld += revenue;
totalSpentHeld += price;
heldCount++;
}
58 replies