Working with CSV Files
More details on:
Write Entity Array to CSV
- <FileName> = 'selected-artworks.csv'
(Artist: "Blake, Robert" ArtistId: "38" Name: "Six Drawings of Figures with Outstretched Arms" Date: "date not known"),
(Artist: "Calvert, Edward" ArtistId: "81" Name: "Ideal Pastoral Life" Date: "1829"),
(Artist: "Sterne, Hedda" ArtistId: "16798" Name: "NY, NY No. X" Date: 1948)
| FileWrite <FileName>
Filter, Transform and Export CSV to JSON
This example does the following things:
- Reads a CSV file containing data about artists
- Filter out all artworks that are not by Robert Blake
- Uppercase the value of the 'artist' property
- Rename 'artist' to 'Artist Name' and 'artistId' to 'ArtistId'
- Sort by the 'year' property
- Distinct by the 'id' property
- Convert to JSON
- Write to a new file
- FileRead 'artwork_data.csv'
| ArrayFilter ((from <> 'artist') == 'Blake, Robert')
| EntityMap (in <> set: 'artist' to: (StringToCase (from <> 'artist') TextCase.Upper))
| EntityMapProperties (artist: 'Artist Name' artistId: 'ArtistId')
| ArraySort (from <> 'year')
| ArrayDistinct (from <> 'id')
| FileWrite 'artwork_data_filtered.json'