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.
text2json
Advanced tools
Readme
Performant parser for textual data
Parsing the following bit of data
id,firstName,lastName,jobTitle
1,Jed,Hoppe,Customer Markets Supervisor
2,Cristian,Miller,Principal Division Specialist
3,Kenyatta,Schimmel,Product Implementation Executive
will produce
[ { id: '1',
firstName: 'Jed',
lastName: 'Hoppe',
jobTitle: 'Customer Markets Supervisor' },
{ id: '2',
firstName: 'Cristian',
lastName: 'Miller',
jobTitle: 'Principal Division Specialist' },
{ id: '3',
firstName: 'Kenyatta',
lastName: 'Schimmel',
jobTitle: 'Product Implementation Executive' } ]
npm install text2json --save
'use strict'
let Parser = require('text2json').Parser
let rawdata = './data/file_100.txt'
let parse = new Parser({hasHeader : true})
parse.text2json (rawdata, (err, data) => {
if (err) {
console.error (err)
} else {
console.log(data)
}
})
'use strict'
let Parser = require('text2json').Parser
let rawdata = './data/file_500000.txt'
let parse = new Parser({hasHeader : true})
parse.text2json (rawdata)
.on('error', (err) => {
console.error (err)
})
.on('headers', (headers) => {
console.log(headers)
})
.on('row', (row) => {
console.log(row)
})
.on('end', () => {
console.log('Done')
})
The parser accepts following options through its constructor (all are optional)
{
hasHeader?: boolean,
headers?: string[],
newline?: string,
separator?: string,
quote?: string,
encoding?: string,
skipRows?: number,
filters?: Filters,
headersOnly?: boolean
}
hasHeader
false
.headers
newline
\n
or \r\n
)\n
separator
,
(comma)quote
"
(double quotes)encoding
(see https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings)
utf-8
skipRows
filters
headersOnly
If hasHeader
is false and custom headers are not specified, parser will generate headers using a zero based index of the columns. i.e. when data has 5 columns, generated headers will be ['_1', '_2', '_3', '_4', '_5']
Header fill will also occur when number of headers given in custom headers array is less than the actual numbers of columns in the data.
headers
- emitted after parsing the header row or once header fill has completed. The payload contains an array of header names.row
- emitted once for every row parsed. Payload is an object with properties corresponding to the header row.error
- emitted once for the first error encountered. Payload is an Error object with an indicative description of the problem.end
- emitted once, when the parser is done parsing. No payload is provided with this event.FAQs
Performant parser for textual data (CSV parser)
The npm package text2json receives a total of 13 weekly downloads. As such, text2json popularity was classified as not popular.
We found that text2json demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.