Re: samples directory (action 20220215-01)

> What do people think about
...
> - A rational form of CSV (if such a thing exists)


I realised I had a special-purpose filter for CSV → XML for my bank accounts that I could convert to ixml, so here goes:


csv: row*.
row: v*-",", nl.
v: quoted; unquoted.
-quoted: -'"', q*, -'"'.
-q: ~['"']; '"', -'"'.
-unquoted: ; ~['",'; #a; #d], c*.
-c: ~[","; #a; #d].
-nl: (-#a; -#d)+.


Example taken from the Wikipedia page on CSV:


Year,Make,Model,Description,Price
1997,Ford,E350,"ac, abs, moon",3000.00
1999,Chevy,"Venture ""Extended Edition""","",4900.00
1999,Chevy,"Venture ""Extended Edition, Very Large""",,5000.00
1996,Jeep,Grand Cherokee,"MUST SELL!
air, moon roof, loaded",4799.00


Result: 


<csv>
   <row>
      <v>Year</v>
      <v>Make</v>
      <v>Model</v>
      <v>Description</v>
      <v>Price</v>
   </row>
   <row>
      <v>1997</v>
      <v>Ford</v>
      <v>E350</v>
      <v>ac, abs, moon</v>
      <v>3000.00</v>
   </row>
   <row>
      <v>1999</v>
      <v>Chevy</v>
      <v>Venture "Extended Edition"</v>
      <v/>
      <v>4900.00</v>
   </row>
   <row>
      <v>1999</v>
      <v>Chevy</v>
      <v>Venture "Extended Edition, Very Large"</v>
      <v/>
      <v>5000.00</v>
   </row>
   <row>
      <v>1996</v>
      <v>Jeep</v>
      <v>Grand Cherokee</v>
      <v>MUST SELL!
air, moon roof, loaded</v>
      <v>4799.00</v>
   </row>
</csv>


Steven

Received on Wednesday, 2 March 2022 13:12:33 UTC