Methods
csvdataToJSON(input) → {string}
Produces the JSON of the csvdata. Uses JSON table schema: http://dataprotocols.org/json-table-schema/
Parameters:
Name | Type | Description |
---|---|---|
input |
string | a csvdata object. |
- Source:
Returns:
JSON represantion of the csvdata object.
- Type
- string
Example
// Given csvdata of:
{ column_names: { "magician", "born"},
rows: { { "houdini", 1874 },
{ "copperfield", 1956} }
}
csvdataToJSON() // will produce:
[ { "magician":"houdini",
"born": 1874 },
{ "magician":"copperfield",
"born":1956 } ]
csvdataToString(input, argdic) → {string}
Produces simple string output of csvdata.
Parameters:
Name | Type | Description |
---|---|---|
input |
string | a csvdata object. |
argdic |
dictionary | arguments for creating the csv string. |
- Source:
Returns:
csv string corresponding to the csvdata object.
- Type
- string
Example
// Given csvdata of:
{ column_names: { "magician", "born"},
rows: { { "houdini", 1874 },
{ "copperfield", 1956} }
}
csvdataToString() // will produce
"magician, born\r\nhoudini, 1874\r\ncopperfield, 1956\r\n"
CSVToJSON(input, argdic) → {string}
Converts CSV string to JSON.
Parameters:
Name | Type | Description |
---|---|---|
input |
string | csv string |
argdic |
dictionary | arguments for parsing the csv string |
- Source:
Returns:
JSON represantion of the csv string.
- Type
- string
Example
CSVToJSON("magician, born\r\nhoudini, 1874\r\ncopperfield, 1956\r\n",
{hasHeaders: true});
// outputs:
[ { "magician":"houdini",
"born": 1874 },
{ "magician":"copperfield",
"born":1956 } ]
findErrors(input) → {Array.<string>}
Find errors.
Parameters:
Name | Type | Description |
---|---|---|
input |
csvdata | input a csvdata object. |
- Source:
Returns:
The errors in the csvdata object.
- Type
- Array.<string>
JSONToCSV(input, argdic) → {string}
Converts JSON to CSV string.
Parameters:
Name | Type | Description |
---|---|---|
input |
string | JSON table string |
argdic |
dictionary | arguments for creating the csv string. |
- Source:
Returns:
csv string corresponding to the JSON input.
- Type
- string
Example
JSONToCSV( [ { "magician":"houdini", "born": 1874 },
{ "magician":"copperfield", "born":1956 } ]);
// outputs:
"magician, born\r\nhoudini, 1874\r\ncopperfield, 1956\r\n",
JSONToCsvdata(jsonStr) → {csvdata}
Produces the csvdata of table formatted JSON Uses JSON table schema: http://dataprotocols.org/json-table-schema/
Parameters:
Name | Type | Description |
---|---|---|
jsonStr |
string | JSON table. |
- Source:
Returns:
the csvdata object representing the JSON input.
- Type
- csvdata
Example
// Given JSON of:
{ "magician":"houdini",
"born": 1874 },
{ "magician":"copperfield",
"born":1956 }
// will produce
{ column_names: { "magician", "born"},
rows: { { "houdini", 1874 },
{ "copperfield", 1956} }
}
makeCsvdataFromObj(obj) → {csvdata}
Can take an object and if the object has the same properties as csvdata, it creates a csvdata from those properties by deep copying.
Parameters:
Name | Type | Description |
---|---|---|
obj |
object | obj Any JS object with csvdata like properties. |
- Source:
Returns:
a new csvdata object deep copied from obj.
- Type
- csvdata
parseString(input, argdic) → {csvdata}
Produces the csvdata of csv string.
Parameters:
Name | Type | Description |
---|---|---|
input |
string | csv string |
argdic |
dictionary | arguments for parsing the csv string |
- Source:
Returns:
the csvdata object representing the csv string.
- Type
- csvdata
Example
parseString("magician, born\r\nhoudini, 1874\r\ncopperfield, 1956\r\n",
{hasHeaders: true});
// will produce
{ column_names: { "magician", "born"},
rows: { { "houdini", 1874 },
{ "copperfield", 1956} }
}