
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
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 62 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.