Get Text File Line?

How can i get a text file and get a string based on a given line?

  • text goes into *.csv or *.json
  • create a struct to represent the data (just a string if that’s all there is - but you can get super crafty with Name identifier, too)
  • import the *.csv file to Unreal
  • turn it into a Data Table
  • the DT can fetch by Name

get a string based on a given line

Providing your rows are numbered, because they do not need to be digits:

Or, to fetch it like non-conformist:


Or, there are plugins that can read directly => Marketplace. But then you’re tied to a plugin.

I was kinda hoping for the other way. Where i can read a file and make table as it reads the line

Not sure what you mean. Make what table? Do you mean the Data Table? Then it’s a no in BPs. Data Table is your text file but Unreal format. You read from it and do stuff with its content.

You can add lines from the DT to an array or a map and them show them in a widget or something. Hard to advise without knowing what is going on.

1 Like

Lets say i have a text file contains of integers. I was hoping for to be possible to read a specific line on the text and get a string.

Then by having a string i can make a ToFloat. And add the given value to Structure Table, instead of typing it manual in. Keypart here is just to get the string by a given line, the rest is easy

Why not just keep floats in the Data Table?

Keypart here is just to get the string by a given line, the rest is easy

That’s the import bit in the original message.

More time efficient in my case, since i have thousands of lines and more

If you already have the floats, just import it. Copy paste to csv/json and you’re golden. No need to even spend time converting expensive strings.

Whaaat, can you import it? how

You can import csv format. Can you show the text flle - just a snippet?


I once imported an actual dictionary, took like 30s of editor hanging.

Not sure if im allowed to share anything, but nothing else than simple lines of intergers array

Fake it. Put fake data in. What are we importing:

Something like this? Or hentai haikus?

I dont have access to Exel, any other file format i can use?
And yes just something like that :slight_smile:

Any text processor can do it.

  • wps is free
  • libra office is free
  • notepad++ can export json
  • google sheets runs in a browser

The last one.

1 Like

I can’t seem to get it to work. Im doing something wrong just not sure what? :smiley:

Here is what i have in the sheet

Yeah, that’s why I asked for a snippet. Your data is already comma separated but needs to be structured differently.

Look at the example in the linked post. You need columns and rows.

And the file needs to be saved as CSV or JSON.


I’ll be around tomorrow afternoon in case Unreal keeps complaining.

Any luck?

If this was the data in the spreadsheet on the left

The plain text format would look like the notepad on the right. You must have rows (here 1-10 but they can be Names instead) and columns (Your, Column, Names, Go…) The *.csv format is so plain, one can take a *.txt file and change its extension to *.csv and it will still work; both ways, too.


So you do not need to use a spreadsheet (but it’s an order of magnitude easier on the mind & on the eyes) and stick with txt:

– ensure the format of the plain text file is correct - columns, rows
– note the comma in the upper left corner
– save plain text file
– change the extension to csv

  • struct:

  • import:

  • DT:

image

Posting this so you can figure out whether this is suitable for your needs.


It may seem complicated but it all takes 1 minute to do but 15 minutes to describe and take screenshots of. :innocent:

Not sure what generates your data. But if you can work in a spreadsheet, it simplifies things.

The best part is the source file is still linked to the DT so you can edit the spreadsheet and reimport with a click. almost run-time

image


One last tip, if you ever create a complex struct - file paths, class references, nested struct arrays and wish to edit the data outside the engine - figuring out the formatting is pretty much impossible. You can then create a DT based on the struct inside the engine and export it:

And now you have a Save Game / Config File editor where you can make mass changes

“MemberVar_3”: [
{
“bMergeMeshes”: false,
“bBakeMatrixAnimation”: true,
“BaseCalculationType”: “PercentageBased”,
“PercentageOfTotalBases”: 100,
“MaxNumberOfBases”: 0,
“MinimumNumberOfVertexInfluencePercentage”: 0
},
{
“bMergeMeshes”: false,
“bBakeMatrixAnimation”: true,
“BaseCalculationType”: “PercentageBased”,
“PercentageOfTotalBases”: 100,
“MaxNumberOfBases”: 0,
“MinimumNumberOfVertexInfluencePercentage”: 0
},
{
“bMergeMeshes”: false,
“bBakeMatrixAnimation”: true,
“BaseCalculationType”: “PercentageBased”,
“PercentageOfTotalBases”: 100,
“MaxNumberOfBases”: 0,
“MinimumNumberOfVertexInfluencePercentage”: 0
},
{
“bMergeMeshes”: false,
“bBakeMatrixAnimation”: true,
“BaseCalculationType”: “PercentageBased”,
“PercentageOfTotalBases”: 100,
“MaxNumberOfBases”: 0,
“MinimumNumberOfVertexInfluencePercentage”: 0
},
{
“bMergeMeshes”: false,
“bBakeMatrixAnimation”: true,
“BaseCalculationType”: “PercentageBased”,
“PercentageOfTotalBases”: 100,
“MaxNumberOfBases”: 0,
“MinimumNumberOfVertexInfluencePercentage”: 0
},

1 Like

Wow thank for all the information, i got it to work <3
But i might stil be looking into read, write and getting lines from file with c++

1 Like