# How can I use my own row struct to create my own datatable?

**URL:** <https://forums.unrealengine.com/t/how-can-i-use-my-own-row-struct-to-create-my-own-datatable/375254>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [November 3, 2016, 3:28am UTC](https://forums.unrealengine.com/t/how-can-i-use-my-own-row-struct-to-create-my-own-datatable/375254 "2016-11-03T03:28:17Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArtainEX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ArtainEX](https://forums.unrealengine.com/u/ArtainEX)\
**Post date:** [November 3, 2016, 3:28am UTC](https://forums.unrealengine.com/t/how-can-i-use-my-own-row-struct-to-create-my-own-datatable/375254/1 "2016-11-03T03:28:17Z")

</div>

USTRUCT(BlueprintType)  
struct FJsonData : public FTableRowBase  
{  
GENERATED\_USTRUCT\_BODY()  
public:  
FJsonData()  
:pid(0)  
{}  
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = “JPhrase”)  
int32 pid;  
};

UCLASS(Blueprintable)  
class BPATTEMPT\_API UJson2DataTable : public UDataTable  
{  
GENERATED\_UCLASS\_BODY()

public:  
UPROPERTY(EditAnywhere, Category = “My Object Properties”)  
FJsonData fjsonData;  
};

As you can see, I have my own structure, and I want to create my own datatable in C++ which will use FJsonData as it’s row structure. How can I set my own structure as DataTable’s row structure?  
Anyone has Idea? I’ve searching google for several days, but there’s no answer.

What I’m trying to do is parsing data and create a datatable asset with it from C++ so that I can use it in Blueprint level.

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [November 3, 2016, 8:14am UTC](https://forums.unrealengine.com/t/how-can-i-use-my-own-row-struct-to-create-my-own-datatable/375254/2 "2016-11-03T08:14:25Z")

</div>

What exactly do you want import to asset or directly use data in asset?

---

<div class="post-metadata">

**Author:** ![ArtainEX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ArtainEX](https://forums.unrealengine.com/u/ArtainEX)\
**Post date:** [November 3, 2016, 7:02pm UTC](https://forums.unrealengine.com/t/how-can-i-use-my-own-row-struct-to-create-my-own-datatable/375254/3 "2016-11-03T19:02:09Z")

</div>

Never mind! I found the way to do that. Will upload how I did that to my website someday.  
What I did is just implementing my own parser so that it can add data to the datatable which is already allocated to the actor

Thanks!

---

<div class="post-metadata">

**Author:** ![ArtainEX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ArtainEX](https://forums.unrealengine.com/u/ArtainEX)\
**Post date:** [November 4, 2016, 12:46am UTC](https://forums.unrealengine.com/t/how-can-i-use-my-own-row-struct-to-create-my-own-datatable/375254/4 "2016-11-04T00:46:44Z")

</div>

I want to create a datatable from the data I parsed from . Which means, I want import in C++ level, and creates an asset.If there’s any way I can creates Datatable with the data I parsed from , that will do too. Actually, Unreal provides functionality to import with certain structure to creates datatable. But when I tried that, it didn’t work properly. Most of the values are wrongly parsed, If you know how to do that, please tell me. Thanks!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_8156b960](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_8156b960](https://forums.unrealengine.com/u/anonymous_user_8156b960)\
**Post date:** [November 9, 2016, 5:40am UTC](https://forums.unrealengine.com/t/how-can-i-use-my-own-row-struct-to-create-my-own-datatable/375254/5 "2016-11-09T05:40:40Z")

</div>

Hello，ArtainEx! Can share give your websitem,what your give may be is very useful to me,Thank you!

---

<div class="post-metadata">

**Author:** ![Atheist91](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Atheist91](https://forums.unrealengine.com/u/Atheist91)\
**Post date:** [November 10, 2016, 12:42pm UTC](https://forums.unrealengine.com/t/how-can-i-use-my-own-row-struct-to-create-my-own-datatable/375254/6 "2016-11-10T12:42:28Z")

</div>

Did you read this?

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

* * *

**Edit:**

Here’s the creation of the datatable using custom struct.

Although, I’m using a C++ struct here, this method will work for **blueprint structs** as well.

```
USTRUCT(Blueprintable)
struct FExampleDatatableRow : public FTableRowBase
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	FString SomeVar;
};

```

[http://i.imgur.com/rMNwYzK.png/](http://i.imgur.com/rMNwYzK.png/)

[http://i.imgur.com/3Zj5MWH.png](http://i.imgur.com/3Zj5MWH.png)

And to get data from such data table in C++:

```
UDataTable* DataTable; // populate it however you want
const FName RowName = FName("SomeRow");
FExampleDatatableRow* FoundRow = DataTable->FindRow<FExampleDatatableRow>(RowName, "");
```

---

<div class="post-metadata">

**Author:** ![ArtainEX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ArtainEX](https://forums.unrealengine.com/u/ArtainEX)\
**Post date:** [November 11, 2016, 1:38am UTC](https://forums.unrealengine.com/t/how-can-i-use-my-own-row-struct-to-create-my-own-datatable/375254/7 "2016-11-11T01:38:51Z")

</div>

Well, basically what I did is creating datatable in UE4 editor level, and allocate it to my actor. Then actor creates the datatable contents based on the structure I defined. What I referenced is Unreal’s parser itself. I’m in the middle of my semester, so detail explanation will be uploaded somewhere around December

---

<div class="post-metadata">

**Author:** ![ArtainEX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ArtainEX](https://forums.unrealengine.com/u/ArtainEX)\
**Post date:** [November 11, 2016, 1:40am UTC](https://forums.unrealengine.com/t/how-can-i-use-my-own-row-struct-to-create-my-own-datatable/375254/8 "2016-11-11T01:40:16Z")

</div>

Thanks for reply, and yes I did. But this is just a reference for how to use datatable which is already created, not creating new datatable.

---

<div class="post-metadata">

**Author:** ![Atheist91](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Atheist91](https://forums.unrealengine.com/u/Atheist91)\
**Post date:** [November 11, 2016, 11:13am UTC](https://forums.unrealengine.com/t/how-can-i-use-my-own-row-struct-to-create-my-own-datatable/375254/9 "2016-11-11T11:13:00Z")

</div>

Alright, i’ve edited my comment and changed it into an answer.  
Hope this helps.

---

<div class="post-metadata">

**Author:** ![Gildor](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gildor](https://forums.unrealengine.com/u/Gildor)\
**Post date:** [November 13, 2016, 1:34pm UTC](https://forums.unrealengine.com/t/how-can-i-use-my-own-row-struct-to-create-my-own-datatable/375254/10 "2016-11-13T13:34:02Z")

</div>

UE4.12 has some troubles with importing UDataTable from . Try switching to 4.13 - all of my problems have gone after this switch.

Regarding import, I did the following.

1. Locate row structure:

2. Create data table:

3. Store to a file. Save file name inside new data table:

4. Call re-import for this table, so all data will be imported into the data table

The code has some capabilities for updating existing table using reimport, which are not listed here. Using DataTableFactory simplifies workflow a lot. For instance, if you’ll update contents of the file, it will be automatically reimported into the engine (with a prompt to user).

Hope this helps.
