There are several solutions to your problem:
- 1. Upload a new dataset
-
set.csv
A,B year,'[2010, 2004, 2005,...]' language,'["English", "Spanish", "Portugues",...]'
where [...] is a JSON array
then in your schema you could do some voodoo magic to parse the JSON array into a Ruby list and choose a random reference... Sorry I just put myself to sleep for a second.Don't do that. Not only would it be tedious and time consuming, but it would require you to limit yourself to a finite number of different years random options.
- 2. Use scripting
-
I have spent an inordinate amount of time over the last week testing the limits of Mockaroo's scripting engine. It is actually quite broad, including
- sequence
-
-
while
i = 0 num = this this = "" while i < num do this += i.to_s + ", " i +=1 end this = this
-
until
this = 0 until random(0, 1) == 0 this += 1 end this = "there were " + this.to_s + " random 0's"
-
each
arr = this this = "" arr.each do |i| this += "#{i}..." end this = this
- etc... (give me a break ruby has a lot of repetition constructs
)
-
- selection
-
-
if
if this this = "it was true" else this = "it was false" end this = this
-
case
case this when 1..5 this = "It's between 1 and 5" when 6 this = "It's 6" else this = "You gave me '" + this.to_s + "' -- I have no idea what to do with that." end this = this
-
unless
unless this.downcase == this this = "'" + this + "' is an uppercase letter" else this = "'" + this + "' is a lower case letter" end this = this
-
- functions
-
def hello() return "hello" end this = hello()
- Data Structures
-
The most notable limitations which i have encountered are:
1. Cannot define classes (as far as I can tell)
2. No static variables (a field cannot reference previous records)
3. Can't see which sequential repetition this record is - my workaround
4. No access to reflection (really hampered my attempts to peek under the api's metaphorical hood)Final thoughts
You can do an awful lot with this scripting API, it will fight you (a lot) sometimes but at the end of the day is greatest weakness is that sometimes it is actually too random (not an insult).
Note
You likely noticed that I always end my formulas by assigning
this = ...
(sometimes eventthis = this
) I don't fully understand why but I have had some bugs occur in the past where formulas were not being evaluated. This seems to solve it. (I have no idea why).