Skip to content

Last Empty Line in CSV Causes Unintended Processing in ParseFileAndSpawnDoodads #28

Description

@StefanoCos

Issue Description:

In the ParseFileAndSpawnDoodads function, the input CSV file can contain a trailing empty line, which causes the function to attempt processing it. This results in unnecessary processing or even errors when accessing fields of the empty line.

Bug Location:
The issue occurs during the iteration over the records from the CSV file in the file ItemCollectionUtility. If the CSV file has a trailing empty line, the code attempts to parse it, causing issues with subsequent logic.

Solution:
The issue is addressed by adding a simple check in the loop to skip any empty records. The check for string.IsNullOrEmpty(record) prevents the code from processing any empty lines, including the last one. This effectively prevents the function from encountering issues related to empty lines at the end of the CSV file.

string[] records = modelPlacementInformation.text.Split(CSV_LINE_SEPERATOR);

foreach (string record in records.Skip(1))
{
    if (string.IsNullOrEmpty(record))
    {
        continue; // Skips empty lines, including the last empty record
    }
    // Further processing...
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions