
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Using npm
npm install @ricb/csv
This project provides functionality to write and read CSV files, as well as parse and serialize CSV data.
","
as separator and "|"
as array separator when writing.See CsvOptions for more info
import { writeCsv, readCsv } from '@ricb/csv';
const data = [
{ id: 1, name: 'John Doe', born: new Date(), nicks: ['man', 'dude'] },
{ id: 2, name: 'Jane Doe', born: new Date('2000-01-01'), nicks: ['girl', 'woman'] }
];
const filePath = await writeCsv(data, 'test.csv');
const loadedData = await readCsv(filePath)
console.log(loadedData);
import { fromCsv, toCsv } from '@ricb/csv'
const text = `Id,Name,Born,Colors,Joined,KidsAge
1,"Doe, John",2000,red|blue,2021-01-01,5|7
2,"Doe, Jane",2001,green|yellow,2021-01-02,3|4
3,"Mouse,Mickey",2002,black|white,2021-01-03,1|2
4,"Mick "The man" Jagger",1943,purple|orange,2021-01-04,8|9`;
const data = await fromCsv(text, { separator: ',' });
const csvText = toCsv(data, { separator: '\t' });
const data2 = await fromCsv(csvText, { separator: '\t' });
console.log(data2);
CsvOptions
is a type that allows you to customize how CSV data is processed. Here are the properties it can have:
fields
: An array of strings specifying the order of the fields when writing CSV data. If not provided, the fields will be written in the order they appear in the data object.
separator
: A string that specifies the character used to separate fields in the CSV data. If not provided, a comma (",") is used by default.
arraySeparator
: A string that specifies the character used to separate array elements in the CSV data. If not provided, a pipe ("|") is used by default.
mapping
: An object that maps field names to their types. This is used when reading CSV data to convert string values to their appropriate types. If not provided, all values are treated as strings.
detectTypes
: A boolean that specifies whether to automatically detect and convert types when reading CSV data. If not provided, this is true
by default.
const options: CsvOptions = {
fields: ['id', 'name', 'born', 'nicks'],
separator: ',',
arraySeparator: '|',
mapping: { id: { type: 'number' }, born: { type: 'date' } },
detectTypes: true
};
const loadedData = await readCsv(filePath, options);
FAQs
Reads and writes data to and from flat files
We found that @ricb/csv demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.