@mosuke_mkii/csv-file
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "@mosuke_mkii/csv-file", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "CSVファイルを操作するモジュール", | ||
@@ -5,0 +5,0 @@ "main": "src/csv-file.js", |
@@ -28,18 +28,27 @@ # CsvFile | ||
// CSVファイルの新規作成とヘッダーの追加 | ||
const csvFile = new CsvFile({ | ||
headers: ['Name', 'Age', 'Gender'], | ||
path: 'example.csv' | ||
}); | ||
await csvFile.createOnlyHeader(); | ||
(async () => { | ||
// CSVファイルの新規作成とヘッダーの追加 | ||
const csvFile = new CsvFile({ | ||
headers: ['Name', 'Age', 'Gender'], | ||
path: 'example.csv' | ||
}); | ||
await csvFile.createOnlyHeader(); | ||
// 既存のCSVファイルへの行の追加 | ||
await csvFile.append([ | ||
['John Doe', '30', 'Male'], | ||
['Jane Doe', '25', 'Female'] | ||
]); | ||
// 既存のCSVファイルへの行の追加 | ||
await csvFile.append([ | ||
['John Doe', '30', 'Male'], | ||
['Jane Doe', '25', 'Female'] | ||
]); | ||
// CSVファイルの読み込みとオブジェクトへの変換 | ||
const rows = await csvFile.convertCsvToArray(); | ||
console.log(rows); | ||
// CSVファイルの読み込みとオブジェクトへの変換 | ||
const rows = await csvFile.convertCsvToArray(); | ||
console.log(rows); | ||
/* | ||
output: | ||
[ | ||
{ Name: 'John Doe', Age: '30', Gender: 'Male' }, | ||
{ Name: 'Jane Doe', Age: '25', Gender: 'Female' } | ||
] | ||
*/ | ||
})(); | ||
``` | ||
@@ -46,0 +55,0 @@ |
17736
57