Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

The CSV library provides functions related to comma separated values. 

Functions

csv:from_array(<entry array>, <field array>)

Formats a CSV string from and array of maps.

This function takes an array of maps representing the entries to be formatted and an array with the desired fields.

If the field array is missing, all the fields in the maps will be returned.

The function assumes that each of the maps in the array have the same keys.  

Example

data = [{
		  "startWaypoint": "-111.712441, 40.332897",
          "cost": "2.02",
          "name": "school",
          "interval": 1372,
          "mileage": "8.7",
          "endWaypoint": "-111.658318, 40.251986",
		  "endTime": "20140829T143628+0000",
          "avgSpeed": "22.8",
          "startTime": "20140829T141336+0000",
          "category": "business"
       },
       {
          "cost": "0.63",
          "startWaypoint": "-111.687001, 40.334647",
          "name": "shopping",
          "interval": 734,
          "mileage": "2.7",
          "endWaypoint": "-111.71217, 40.332837",
	      "endTime": "20140829T132710+0000",
          "avgSpeed": "13.2",
          "startTime": "20140829T131456+0000",
          "category": ""
      }]
csv = csv:from_array(data)
 
//cost,startWaypoint,name,interval,mileage,endWaypoint,endTime,avgSpeed,category,startTime
//2.02,"-111.712441, 40.332897",school,1372,8.7,"-111.658318, 40.251986",20140829T143628+0000,22.8,business,20140829T141336+0000
//0.63,"-111.687001, 40.334647",shopping,734,2.7,"-111.71217, 40.332837",20140829T132710+0000,13.2,,20140829T131456+0000


 
  • No labels