Author Topic: Versatile Separated Values (VSV)  (Read 100 times)

Den

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1080
  • Selina is my Superstar
    • View Profile
    • Amuseum
Versatile Separated Values (VSV)
« on: November 12, 2017, 06:05:20 AM »
Versatile Separated Values (VSV)

Proposal: A versatile, efficient, unambiguous, standardized, simple text format for creating tables and lists that's easily read and created by both humans and machines, that supports many variations for any personal style, preferences, and protocols. Can accept any nonspace character (including comma, colon, tab, asterisk, etc.) as delimiter automatically without user input (no annoying popups or options to fill in).

The same simple algorithm will accept almost any delimiter you want. You want commas like CSV? No problem. Or fields separated by tab (TSV)? Sure. How about *NIX files that use colons? We'll take it. Want to mix them up in the same table or file? Go ahead.

Exporting to VSV (creating files)

Rows are separated by newline. 

Header rows are optional. Each header field is enclosed by any of these double matching bracket types:
Code: [Select]
[[]]
{{}}
(())
<<>>

Different header fields may use different brackets types. Mixed bracket types may be employed on the same header row.

When exporting to a VSV file, characters that are found in a header field must not be used as enclosing brackets for that field. Choose a bracket not found in that field to surround that field.

Data rows (non headers) must be led by an explicit nonspace character, called delimiter. Values for that row are placed between two delimiters. The first occurrence of a delimiter on that row is not counted as part of the values.

A null value has zero length, signified by consecutive delimiters with nothing in between them.

A delimiter at the end of the line after the final value is optional, unless the final value is a null value.

Each row may have its own distinct delimiter. A text file may have different rows with various delimiters. Creators can use the same delimiters or mix them for different rows, as long as the desired values on that row are distinguishable (i.e. to prevent delimiter collision.)

When exporting to a VSV file, characters that are found in the values of a given row must not be used as delimiter for that row. Choose a character not found in that row's values as the delimiter for that row.
  • Space and newline cannot be used as delimiter. Any other single character may be used.
  • Letters and numbers may be used as delimiters, but are not recommended.
  • Avoid using header field brackets as data row delimiters. Nevertheless, single bracket at beginning of a row should be read as a legal delimiter.
  • Creators may have their own preferred delimiters. Common delimiters to use:
Code: [Select]
,
:
|
;
*
-
@
#
%
~
TAB

Importing VSV (reading files)

Rows are separated by newline. Leading spaces on each row are discarded and ignored.

If the first two nonspace characters of a row are identical opening brackets, this is a header row. Else it is a data row.

Header fields must be enclosed by both an opening and a closing matching double brackets. Any other text on a header row is discarded and ignored.

The first nonspace character of a data row is its delimiter. The values of this row are stored between two delimiters or the end of line. A value can have zero length, or null value. There is no value between a line-ending delimiter and end of line (it doesn't count as another value, not even null value).

In PHP, use the explode() function to store a row's values into an array split by the delimiter. For other languages, use a regexp to match the values separated by the delimiter.

Examples

See : http://shenafu.com/smf/index.php?topic=203.msg2089#msg2089

Questions

How to handle values that contain newline?
Can it be used for objects or hierarchy? i.e. in place of JSON, XML, HTML
Can it be used as configuration file? cf. INI, CONF files
« Last Edit: Yesterday at 07:33:19 AM by Den »
Support me on Patreon

I saw. I conquered. I came.

ADMIN

  • Administrator
  • Member
  • *****
  • Posts: 24
    • View Profile
Downloads for VSV
« Reply #1 on: November 13, 2017, 11:39:48 PM »
« Last Edit: November 13, 2017, 11:42:05 PM by Den »

Den

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1080
  • Selina is my Superstar
    • View Profile
    • Amuseum
Re: Versatile Separated Values (VSV)
« Reply #2 on: November 15, 2017, 07:58:13 AM »
VSV Usage examples and comparison to other formats


VSV as Tabular Data

Double Matching Brackets are header fields (optional)
Everything else are data rows

(When using the Comma , as delimiter, similar to CSV)

Code: [Select]
[tables=vsv]
((Name)) ((Score 1)) ((Score 2))
,BEAKL 8, 104, 132
,BEAKL 9, 120, 144
,BEAKL 10, 44, 99
[/tables]

NameScore 1Score 2
BEAKL 8 104 132
BEAKL 9 120 144
BEAKL 10 44 99


(Can use any nonspace character as delimiter--lots of freedom)

Code: [Select]
[tables=vsv]
[[Name]] {{Age}} ((Gender))
,Hammie, 20.5, F
-Chow, Vivian-40-F
:Amuseum:25:M:
*Shena'Fu *18+5/12 *F
|Grndr-1245|21 months||
Fairy Nuff 14 K N/A
[/tables]

NameAgeGender
Hammie 20.5 F
Chow, Vivian40F
Amuseum25M
Shena'Fu 18+5/12 F
Grndr-124521 months
Fairy Nuff14 KN/A



VSV as Linux password file

The Colon :  starts each line and separates each field

Code: [Select]
:smithj:x:561:561:Joe Smith:/home/smithj:/bin/bash


VSV as configuration file

Double Square Brackets [[ starts each section
Double Round Brackets (( are comments and help
The Equal = starts each line and separates the setting key from its value

Code: [Select]
[[General]]
((display options: fullscreen, windowed, windowedmax))
=display=fullscreen
=width=1920
=height=1080


VSV as XML replacement

Double Angled Brackets << as tags
Close innermost tag with the Slash / inside double brackets
Data rows as attributes and content
Use spaces to indent

Code: [Select]
<<note>>
 <<to>>
  ~txt~Tove
 <</>>
 <<from>>
  ~txt~Jani
 <</>>
 <<heading>>
  ~txt~Reminder
 <</>>
 <<body>>
  <<p>>
   =width=600
   ~txt~Don't forget me this weekend!
  <</>>
 <</>>
<</>>


VSV as Objects and Arrays

Double Curly Brackets {{ as Objects
Double Square Brackets [[ as Arrays
Close innermost object or array with the Semicolon ; inside double brackets
Data rows as properties
Use spaces to indent

Code: [Select]
{{}}
 {{menu}}
  ~id~file
  ~value~File
  {{popup}}
   [[menuitem]]
    {{0}}
     ~value~New
     ~onclick~CreateNewDoc()
    {{;}}
    {{1}}
     ~value~Open
     ~onclick~OpenDoc()
    {{;}}
    {{2}}
     ~value~Close
     ~onclick~CloseDoc()
    {{;}}
   [[;]]
  {{;}}
 {{;}}
{{;}}


« Last Edit: Yesterday at 07:35:25 AM by Den »