Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
trcsvjs
Advanced tools
Readme
A csv manager module for node and browser. This module wrapp papaparse library and add extra features. See papaparse page for more information: https://www.npmjs.com/package/papaparse
Include in Browser
// ....
<script type='text/javascript' src='PATH/TO/LIB/node_modules/papaparse/papaparse.min.js?'></script>
<script type='text/javascript' src='PATH/TO/LIB/trcsvjs.min.js?'></script>
// Trcsvjs available
// ....
Declare in NodeJs
npm install trcsvjs
//....
var Trcsvjs = require('trcsvjs')
Library Trcsvjs implement a list of functions that allow to create a csv object
// Create csv object from string CSV_STRING
Trcsvjs.csvStringToJs(CSV_STRING[,config],callback) //callback(err,csv)
// Create csv object from file getted from DOM
Trcsvjs.getCsvFromFile(ELEMENT_FILE_FROM_DOM[,config],callback) //callback(err,csv)
// Create csv object from csv in URL
Trcsvjs.getCsvFromUrl(URL[,config],callback) //callback(err,csv)
// Create empty csv object
var csv = Trcsvjs.getEmptyCsv([config])
Config use same parameters than papaparse. See papaparse page for more information: https://www.npmjs.com/package/papaparse
After you create a csv object, you can manage it using its function. All reference to position for column and row start at 1..n
//Init csv using directly an array of array [[],[],[],[]] -> [ROW,ROW,ROW,..]
csv.initCsvFromArray(array);
//Return cell value in column "col" of row "pos"
var value = csv.getCell(pos, col);
//Return cell value in column "col" of row "pos"
var value = csv.getCell(pos, col);
//Set value of cell in column "col" of row "pos"
csv.setCell(pos, col, value);
//Return all csv converted in string
var text = csv.getCsvText(config); //use papaparse, config of papaparse
//Create a file in browser and force download (not in NodeJs)
csv.browseCsv(filename, config); //use papaparse, config of papaparse
//Return row (array[]) in position "pos"
var row = csv.getRow(pos);
//Return row converted in object from row in position "pos". To convert row in object use objspec
var obj = csv.getObjFromRow(pos, objspec);
//Return row array convertirg an object into a row. To convert object in row use objspec
var row = csv.getRowFromObj(pos, objspec);
//Insert row (array[]) at the end of file
csv.insertRow(row);
//Insert row (array[]) at position pos
csv.insertRowInPos(row, pos);
//Insert row convertif first from object
csv.insertRowFromObj(obj, objspec);
csv.insertRowInPosFromObj(obj, pos, objspec);
You can create easly an object from a row using an object spec. An object spec is like:
{
"name_field_1":CONF_FIELD,
"name_field_2":CONF_FIELD,
}
If you have a row like ['foo','bar'] and convert in object using previous spec you receive an object:
{
"name_field_1" : 'foo',
"name_field_2" : 'bar'
}
It also accept deep objects, for example:
{
"a" : {
"a1" : {
"a11" : CONF_FIELD,
"a12" : CONF_FIELD
},
"a2" : CONF_FIELD
},
"b" : "CONF_FIELD
}
convert row [1,2,3,4] in:
{
"a" : {
"a1" : {
"a11" : 1,
""a12" : 2
},
"a2" : 2
},
"b" : "3
}
Also, if you use object spec to convert an object in array (row) the process is exactly the opposite
Conf field is a special configuration that allow to automaticaly implement typical process to a value before converting to object/array. Valid values are:
FAQs
A csv parser that use papaparser and extend its features
The npm package trcsvjs receives a total of 2 weekly downloads. As such, trcsvjs popularity was classified as not popular.
We found that trcsvjs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.