Gathering detailed insights and metrics for objects-to-csv
Gathering detailed insights and metrics for objects-to-csv
Gathering detailed insights and metrics for objects-to-csv
Gathering detailed insights and metrics for objects-to-csv
@types/objects-to-csv
TypeScript definitions for objects-to-csv
tabletojson
Convert HTML tables to JSON objects
alasql
Use SQL to select and filter javascript data - including relational joins and search in nested objects (JSON). Export to and import from Excel and CSV
to-csv
Convert objects to CSV
Converts an array of JavaScript objects into a CSV file, optionally saving it to filesystem.
npm install objects-to-csv
Typescript
Module System
Node Version
NPM Version
50.9
Supply Chain
99.5
Quality
76
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
12,952,790
Last Day
14,094
Last Week
123,705
Last Month
638,764
Last Year
4,946,890
100 Stars
39 Commits
39 Forks
4 Watching
11 Branches
2 Contributors
Latest Version
1.3.6
Package Id
objects-to-csv@1.3.6
Size
4.57 kB
NPM Version
6.9.0
Node Version
10.16.3
Publised On
04 Jan 2020
Cumulative downloads
Total Downloads
Last day
-39.1%
14,094
Compared to previous day
Last week
-24.9%
123,705
Compared to previous week
Last month
21.6%
638,764
Compared to previous month
Last year
62.8%
4,946,890
Compared to previous year
Converts an array of JavaScript objects into the CSV format. You can save the CSV to file or return it as a string.
The keys in the first object of the array will be used as column names.
Any special characters in the values (such as commas) will be properly escaped.
1const ObjectsToCsv = require('objects-to-csv'); 2 3// Sample data - two columns, three rows: 4const data = [ 5 {code: 'CA', name: 'California'}, 6 {code: 'TX', name: 'Texas'}, 7 {code: 'NY', name: 'New York'}, 8]; 9 10// If you use "await", code must be inside an asynchronous function: 11(async () => { 12 const csv = new ObjectsToCsv(data); 13 14 // Save to file: 15 await csv.toDisk('./test.csv'); 16 17 // Return the CSV file as string: 18 console.log(await csv.toString()); 19})();
There are two methods, toDisk(filename)
and toString()
.
Converts the data and saves the CSV file to disk. The filename
must include the
path as well.
The options
is an optional parameter which is an object that contains the
settings. Supported options:
append
- whether to append to the file. Default is false
(overwrite the file).
Set to true
to append. Column names will be added only once at the beginning
of the file. If the file does not exist, it will be created.bom
- whether to add the Unicode Byte Order Mark at the beginning of the
file. Default is false
; set to true
to be able to view Unicode in Excel
properly. Otherwise Excel will display Unicode incorrectly.allColumns
- whether to check all array items for keys to convert to columns rather
than only the first. This will sort the columns alphabetically. Default is false
;
set to true
to check all items for potential column names.1const ObjectsToCsv = require('objects-to-csv');
2const sampleData = [{ id: 1, text: 'this is a test' }];
3
4// Run asynchronously, without awaiting:
5new ObjectsToCsv(sampleData).toDisk('./test.csv');
6
7// Alternatively, you can append to the existing file:
8new ObjectsToCsv(sampleData).toDisk('./test.csv', { append: true });
9
10// `allColumns: true` collects column names from all objects in the array,
11// instead of only using the first one. In this case the CSV file will
12// contain three columns:
13const mixedData = [
14 { id: 1, name: 'California' },
15 { id: 2, description: 'A long description.' },
16];
17new ObjectsToCsv(mixedData).toDisk('./test.csv', { allColumns: true });
Returns the CSV file as a string.
Two optional parameters are available:
header
controls whether the column names will be
returned as the first row of the file. Default is true
. Set it to false
to
get only the data rows, without the column names.allColumns
controls whether to check every item for potential keys to process,
rather than only the first item; this will sort the columns alphabetically by key name.
Default is false
. Set it to true
to process keys that may not be present
in the first object of the array.1const ObjectsToCsv = require('objects-to-csv'); 2const sampleData = [{ id: 1, text: 'this is a test' }]; 3 4async function printCsv(data) { 5 console.log( 6 await new ObjectsToCsv(data).toString() 7 ); 8} 9 10printCsv(sampleData);
Use Node.js version 8 or above.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 2/14 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
37 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-12-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More