CSV files and modding


I tried and used the CSV import feature and created datatables. It works fine.
However, when I use the data or watching the cooking results, my CSV is converted to an .uasset file.
My problem is with that I need keep the CSV files for modding purposes. Modders must have the option to edit the data files.
Can I import data from CSV file by C++ directly or I need code this manually?
Or maybe there is an option to make an importer/exporter utility for modders which extracts it in CSV form, and cooks it again to .uasset?


I’m not an unreal engine expert, but looking through the API I think you could use UDataTable::CreateTableFromCSVString | Unreal Engine Documentation to create data table from csv (as string - file read as string)…

thanks, after some struggling with dynamic creation of my UDataTable, I was able to run it without errors, now Im getting messages of the very method in an array.

	FString sFile = "../../DataBase/territories.csv";
	FFileHelper::LoadFileToString(sData, *sFile);
	Problems = dtTerritories->CreateTableFromCSVString(sData);
	wofstream of("f:/csvimporterror.log", 'w');

	for (int32 ProbIdx = 0; ProbIdx < Problems.Num(); ProbIdx++)
		// Output problems to log
		of << TCHAR_TO_ANSI(*Problems[ProbIdx]) << "


my file has this message:

Too few rows.

wth? :slight_smile: what it does mean… it is definitely not empty, but what is too few :open_mouth:
maybe it has problems with line endings, at least I dont see other cause from method source…

okay, it is solved, my file path was bad :smiley:
seems import ok, though I still cant access to data, it crashes when I want query the rows…

	GameObjectLookupTable.DataTable = dtTerritories;
	int32 maxItems = GameObjectLookupTable.DataTable->GetTableData().Num();

Have you tried to debug it? What’s behind the crash? Access violation? Is dtTerritories valid?

Using the datatables built in are going to require that you use the uasset format, for the most part thats true for all built in tools/types. For Flathead though, I found that you can load arbitrary files quite easily using standard C++ utility classes.

The only parts that might be irritating are - because you have deviated you should be aware that reading/writing from disc is something to do be done at load time, not mid frame, and that you will need to do the parsing. That can likely be handled elsewhere though, abstract the complexity away where possible.

Also, you may be better off using the FPaths functions to avoid relative path guessing: