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?


#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?