Error Import CSV with realm studio


#1

Hi, when I import a string field that starts with a number I obtain an error.

Sample:

ID->string
Desc->string

ID;Desc
0001;MyDesc

Error!


#2

That’s not a CSV file. CSV is Comma Separated Values format and yours are separated with a semicolon ;

the first line of your file needs to match the objects properties, and the lines after that are the individual object values for those properties.

So if you have a class

PersonClass: Object {
   @objc dynamic var person_name = ""
   @objc dynamic var fav_food = ""
}

the import file should look like this

person_name,fav_food
Frank,Pizza
Larry,Steak
Leroy,Tacos
0123Bill,Chicken

and I tested importing strings that start with a number and they import just fine so the 0123Bill line worked correctly.


#3

Thanks!!!

It works!

Luigi


#5

Sorry Jay, but if column is not primary key and string contains only number don’t work

0123Bill ok
0123 ko…

I think it’s a Realm Studio Bug


#6

@luigi.degiacomo

I don’t know what this is,

0123Bill ok
0123 ko…

but it isn’t in the correct format to be imported - I demonstrated the correct format in my answer above.

To test (again) I created a new class in Realm Studio called TestClass with two properties test_name and test_food

TestClass: Object {
   @objc dynamic var test_name = ""
   @objc dynamic var test_food = ""
}

I then created a .csv file like this

test_name,test_food
Frank,Pizza
Larry,Steak
0123Bill,ok
0123 Frank,ok

and then saved the file with the proper name TestClass.csv

Then, using Realm Studio, I selected the class and then imported the TestClass.csv file. It imported correctly and 4 TestClass objects were added.