Import CSV using realm studio


#1

I am developing an app and need to hardcode objects into my realm. I may need to clear the realm during development and do not want to have to manually type in the objects every time. I see there is a way to import a CSV file into a realm but I do not really see any instructions on how to do it. How can I import a CSV file to save me some time?


Page Not Found - IP Blocked
#2

Check out the Realm Studio docs. They have a (small) section about importing from CSV: https://docs.realm.io/platform/realm-studio/view-your-data#importing-data


#3

Thank you, that is exactly what I was looking for


#4

So I think I have figured everything out except how to add a boolean value into the csv. I have a property name isLiquor that is a boolean, when I import the csv I get an error saying to add a value for isLiquor. I tried creating a realm from the csv file and it works but it is reading my boolean value as a string. How can I specify that my value is a boolean?


#5

@alexander Also how to you include list references in a csv file? I have a property call ingredients that holds references to my Ingredient model?


#6

To determine the type of a column the importer looks at the data row - if its either “true” or “false” it will guess bool? for the property type - for example, this Person.csv

name,isHappy
Alice,true
Bob,false

Will yeild a single class named Person with two properties:

  • name of type optional string and
  • isHappy of type optional boolean.

At the moment only bool, int, double and string types are supported when importing from CVS, we want to add relations as well, but has unfortunately not yet implemented that.


#7

I have the same question also, How can I import the RealmList?


#8

This link shows “Page Not Found” and I am having trouble finding documentation on how to import data with CSV. I see there is the option from File menu but I feel there’s a good resource somewhere around here on best practices!

Thanks for any response!


#9

This topic has been discussed a number of times here. Check out this post for an example of how to read a CSV file


#10

Does this link show for you?

https://docs.realm.io/sync/realm-studio/view-your-data#importing-data

This is the one that shows “Page Not Found”. This is the link @alexander posted linking to the Realm Studio Documents. I’m familiar with what a CSV file looks like, the post you linked is not my current issue. I know how to read a CSV, I know how to export from excel and many other sources as CSV. I’m specifically looking for the documentation linked above that comes up as Page Now Found. Thanks for any assistance.


#11

then

I know how to read a CSV

That link is dead and replaced with more current documentation. However, your two posts are somewhat conflicting - if you can tell us specifically what you need help with or what function documentation you need, we may be able to point you to it.

Just trying to help but please help us to help you by being more specific.


#12

I do not know how to be more specific.

You stated it has now been replaced with more current documentation, can you link that new documentation on importing CSV files into Realm? I’m not meaning to be too vague or snippy, I just really want formal documentation from Realm on importing information using CSV files and their limitations.

How do I handle cells with no data? Can I use the “?” optional operator to handle empty cells before exporting to CSV?

I imagine you will respond much faster than any Realm moderator so I greatly appreciate your attention on this. Thank you, @jay


#13

All I can tell you is to not overthink this. I asked for details as if you can ask a specific question about what you want to do, other than ‘where’s the docs’ we may be a bit more helpful.

The docs are here Importing Data

There are no parameters, limitations, options or settings to modify. It’s a straight-forward dumb import. Your file has to be in the correct format or the import will fail. See the response from @kraenhansen above as it still applies and the post I linked above as it has actual working sample and code.


#14

sigh I can’t help it :expressionless:

Thank you for the response, @jay!

I’m going to just build my spreadsheet then continuously export it until it looks right!