Greetings,
So I am currently trying to load a list of individuals from a .csv file.
Now it loads everything fine, displays it correctly in the debug log HOWEVER, it always crashes when I attempt to put it in an FString.
csv is formatted as such, was created and saved with Excel:
firstName, middleName, lastName, date, month, year
Code:
TArray<FString> AFileHandler::LoadIndividualsFile() {
TArray<FString> data;
FString temp;
FString fileLocation = "C:\\FULLPATH-HERE-FOR-TESTING-PURPOSES-ONLY\\Data\\testIndividuals.csv";
TArray<FString> fromFile;
FFileHelper::LoadANSITextFileToStrings(*fileLocation, NULL, fromFile);
for (int i = 0; i < fromFile.Num(); i++) {
FString aString = fromFile[i];
TArray<FString> stringArray = {};
aString.ParseIntoArray(stringArray, TEXT(","), false);
for (int j = 0; j < stringArray.Num(); j++) {
UE_LOG(LogTemp, Warning, TEXT("%d == %s"), j, *stringArray[j]);
}
temp = stringArray[2]; // <--- this breaks it
//temp += stringArray[0] + " ";
//temp += stringArray[1];
//data.Add(temp);
}
return data;
}
I want to display the name in: Last, First Middle - hence the three lines for it
It always crashes when I attempt to put stringArray[someIndex] into a FString (or add it to data for that matter), however the log works fine.
From all the examples I have see this should be working.
Any ideas on what I am doing wrong?
Thanks!