I have a tree structural data(parent child) to export into CSV.
Is there any standard format to display the data in a meaningful way and maybe for future usage?
Currently I am considering using empty "", to denote the next level.
CSV , or Comma-separated Values, is an extremely common flat-file format that uses commas as a delimiter between values. Anyone familiar with spreadsheet programs has very likely encountered CSV files before - they're easily consumed by Google Spreadsheet, Microsoft Excel, and countless other applications.
SQLite facilitates you to export data from SQLite database to CSV file.
A comma-separated values (CSV) file is a delimited text file that uses a comma to separate values. Each line of the file is a data record. Each record consists of one or more fields, separated by commas. The use of the comma as a field separator is the source of the name for this file format.
A CSV (comma-separated values) file is a text file that has a specific format which allows data to be saved in a table structured format.
Well, there is no standard here, at least not something I'm aware of. It usually comes to performance aspects, the ease of usage and the size of tree.
I can offer you to store the tree as a pairs of parent son relation, and then you'll be able to recreate the tree.
Example:
Lets assume, you have a tree:
root
a
b
c
This can be expressed like series of relations:
root --> a
root --> b
b --> c
This is exactly what you can store in the file:
root,a
root,b
b,c
Another interesting method can be used given the fact that the tree (at least binary tree) can be represented as an array
This will let you store the single line in your csv file since the array is linear and it naturally maps into an array I'm sure you can find much more ways to store the tree, the sky is a limit here, I've just pointed you a few.
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With