Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
data-file-parser
Advanced tools
parse data from file using regular expression (regex)
This plugin requires Grunt ~0.4.0
you may install this module with this command:
npm install data-file-parser --save-dev
after instalation you can load it like so
var dataFileParser = require('data-file-parser');
Returns: Q promise object
Type: String
Required
path to input file wich will be parsed
Type: String
Default: utf8
encoding in which input file is written this option is passed to fs.readFile function
Type: String
Required
path to output file in wich parsed data will be written
Type: RegExp
Required
Example:/^([a-z]+) ([a-z]+). (.+)/gim,
using this regular expresion will be parsed input file. you should use at list one group in it.
Type: String
Required
Example: 'word|type|desc'
it should contain keys (seperated using '|' ) of parsed data using thous keys will be generated date items in output.
Type: String
Default: false
name of variable to wich parsed data vill be esigned and will be written. it should be saved as '*.js' file and then included using script tag so thet variable vill be available
this is content of words.txt
abase v. To lower in position, estimation, or the like;
abbess n. The lady superior of a nunnery.
abbey n. The group of buildings which collectively form the dwelling-place of a society of monks or nuns.
abbot n. The superior of a community of monks.
abdicate v. To give up (royal power or the like).
abdomen n. In mammals, the visceral cavity between the diaphragm and the pelvic floor; the belly.
abdominal n. Of, pertaining to, or situated on the abdomen.
abduction n. A carrying away of a person against his will, or illegally.
this is index.js
var dataParser = require('data-file-parser');
dataParser.parse({
in: 'words.txt', //input file
out: 'words.js', //output file
var:'words', //variable name
// g for global
// i for ignore case
// m fot ^ to be start of every line not whole string
regex: /^([a-z\-]+) ([a-z]+)\. (.+)/gim,
as:'word|type|desc' //object keys
}).then(function(arr){
console.log(arr.length+" words");
})
so after runing it
node index.js
this will be in wors.js
var words = [
{
"word": "abase",
"type": "v",
"desc": "To lower in position, estimation, or the like;"
},
{
"word": "abbess",
"type": "n",
"desc": "The lady superior of a nunnery. "
},
{
"word": "abbey",
"type": "n",
"desc": "The group of buildings which collectively form the dwelling-place of a society of monks or nuns."
},
{
"word": "abbot",
"type": "n",
"desc": "The superior of a community of monks. "
},
{
"word": "abdicate",
"type": "v",
"desc": "To give up (royal power or the like). "
},
{
"word": "abdomen",
"type": "n",
"desc": "In mammals, the visceral cavity between the diaphragm and the pelvic floor; the belly. "
},
{
"word": "abdominal",
"type": "n",
"desc": "Of, pertaining to, or situated on the abdomen. "
},
{
"word": "abduction",
"type": "n",
"desc": "A carrying away of a person against his will, or illegally. "
}
];
and it will be ready to use in your static web project or whatever
// Project configuration.
<script src="words.js"></script>
<script>
console.log(words.length);
</script>
author Irakli Safareli
FAQs
node module for parsing file and writing into another file
The npm package data-file-parser receives a total of 0 weekly downloads. As such, data-file-parser popularity was classified as not popular.
We found that data-file-parser 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.