Skip to content
Kyle Kukshtel edited this page Oct 13, 2020 · 4 revisions

Importing

JSON Importing?

Short answer: Probably not.

Long answer: JSON is fundamentally unstructured. Keys and value can be nearly anything, which is great if you know how to perfectly interpret a given JSON object inside of your code, but it also means there is no deterministic way to parse the data. Consider something as simple as this:

{ 
   "key" : 23.5
}

What exactly is key? Is it a float? Short? Long? Is it actually supposed to be an Int but the data was mis-entered? Across larger JSON data sets the problem multiples, especially with nested vales and arrays that have no determination about what they should be. What if key above was actually supposed to be an array but the user left out the []? There's not really any way to know.

Because the pitch of Depot is that it's about editing structured data, I'm very wary to even attempt a basic JSON importer because I suspect it would either: A) Be so general that it's not useful and you'd have to convert tons of columns to the point where you could have just made a new Depot file. B) Be so specific that nothing is able to be imported due to inconsistences.

What Should I Do If I Still Want To Import JSON?

If your data is structured and follows a specific scheme, you should be able to pretty easily create your schema in a Depot file. After you've created your schema, you can either enter you lines manually, or use a simple program like jq to parse your existing JSON and emit an array of lines in Depot's format that you can just hand copy and paste into your Depot file. It's not a great solution, but it should get you most of the way.

CSV Importing?

Maybe! What this would probably be is a command in Code that you invoke with an open .CSV file that reads in the contents of the .CSV file and outputs a Depot file. You wouldn't be able to save changes back to your .CSV file, but your data should be maintained. One concession here is that all the data would be imported as strings, and then once column conversion is implemented you would just go through and convert the columns to the relevant types.

CastleDB / .cdb Importing?

Eventually, but hard to say when. CDB and DPO files are very similar, however right now Depot offers a subset of the functionality of Castle. What I wouldn't want is to give people the impression there is exact parity between the formats and people lose data as part of the conversion process. Once there is "sufficient" parity I'd like to make an importer for the files, but in the meantime you can reference some of the key differences between Depot and CastleDB here to better understand how you could hand edit a CDB file to be DPO compatible.