Skip to content

Commit cd4a99c

Browse files
committed
Update jsdoc in reader
1 parent ae1ede3 commit cd4a99c

2 files changed

Lines changed: 33 additions & 20 deletions

File tree

danfojs-browser/src/io/reader.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ import { DataFrame } from "../core/frame";
55

66
/**
77
* Reads a CSV file from local or remote storage
8-
*
9-
* @param {source} URL to CSV file
10-
* @param {config} (Optional). A CSV Config object that contains configurations
8+
* @param {string} source URL to CSV file
9+
* @param {object} config (Optional). A CSV Config object that contains configurations
1110
* for reading and decoding from CSV file(s).
11+
* { start: The index position to start from when reading the CSV file.
12+
*
13+
* end: The end position to stop at when reading the CSV file.
14+
*
15+
* ...csvConfigs: other supported Tensorflow csvConfig parameters. See https://js.tensorflow.org/api/latest/#data.csv
16+
* }
1217
*
1318
* @returns {Promise} DataFrame structure of parsed CSV data
1419
*/
@@ -30,8 +35,7 @@ export const read_csv = async (source, configs = {}) => {
3035

3136
/**
3237
* Reads a JSON file from local or remote address
33-
*
34-
* @param {source} URL or local file path to retreive JSON file.
38+
* @param {string} source URL or local file path to retreive JSON file.
3539
* @returns {Promise} DataFrame structure of parsed CSV data
3640
*/
3741
export const read_json = async (source) => {
@@ -44,12 +48,15 @@ export const read_json = async (source) => {
4448

4549
/**
4650
* Reads an Excel file from local or remote address
51+
* @param {string} source URL to Excel file
52+
* @param {object} configs {
53+
*
54+
* sheet : string, (Optional) Name of the sheet which u want to parse. Default will be the first sheet.
4755
*
48-
* * @param {kwargs} kwargs --> {
49-
* source : string, URL or local file path to retreive Excel file.
50-
* sheet : string, (Optional) Name of the sheet which u want to parse. Default will be the first sheet.
5156
* header_index : int, (Optional) Index of the row which represents the header(columns) of the data. Default will be the first non empty row.
52-
* data_index : int, (Optional)Index of the row from which actual data(content) starts. Default will be the next row of `header_index`
57+
*
58+
* data_index : int, (Optional) Index of the row from which actual data(content) starts. Default will be the next row of `header_index`.
59+
*
5360
* }
5461
* @returns {Promise} DataFrame structure of parsed Excel data
5562
*/

danfojs-node/src/io/reader.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ export const read_json = async (source) => {
6565

6666
/**
6767
* Reads an Excel file from local or remote address
68-
* * @param {kwargs} kwargs --> {
69-
* source : string, URL or local file path to retreive Excel file
70-
* configs: object, (Optional) {
68+
* @param {string} source URL or local file path to retreive Excel file.
69+
* @param {object} configs (Optional) Configuration options when reading excel files
70+
*
71+
* {
7172
* sheet : string, (Optional) number of the sheet to parse. Default will be the first sheet.
7273
* }
7374
* @returns {Promise} DataFrame structure of parsed Excel data
@@ -79,33 +80,38 @@ export const read_excel = async (source, configs) => {
7980

8081
/**
8182
* Opens a file using frictionless.js specification.
82-
* @param {string} pathOrDescriptor A path to the file/resources. It can be a local file,
83+
* @param {string} source A path to the file/resources. It can be a local file,
8384
* a URL to a tabular data (CSV, EXCEL) or Datahub.io Data Resource.
8485
* Data comes with extra properties and specification conforming to the Frictionless Data standards.
85-
* @param {object} configs { data_num (Defaults => 0): The specific dataset to load, when reading data from a datapackage.json,
86-
* header (Defaults => true): Whether the dataset contains header or not.
87-
* }
86+
* @param {object} configs {
87+
*
88+
* data_num (Defaults => 0): The specific dataset to load, when reading data from a datapackage.json
89+
*
90+
* header (Defaults => true): Whether the dataset contains header or not.
91+
*
92+
* sheet (Defaults => 0): Number of the excel sheet which u want to load.
93+
* }
8894
* @returns {DataFrame} Danfo DataFrame/Series
8995
*/
9096
export const read = async (
91-
path_or_descriptor,
97+
source,
9298
configs = {}
9399
) => {
94100
let { data_num, header, sheet } = configs;
95101
data_num = data_num === undefined ? 0 : data_num;
96102
header = header === undefined ? true : header;
97103
let rows, file;
98104

99-
if (isDataset(path_or_descriptor)) {
105+
if (isDataset(source)) {
100106
console.log(
101107
"datapackage.json found. Loading Dataset package from Datahub.io"
102108
);
103-
const dataset = await Dataset.load(path_or_descriptor);
109+
const dataset = await Dataset.load(source);
104110
file = dataset.resources[data_num];
105111
rows = await toArray(await file.rows());
106112
} else {
107113
try {
108-
file = open(path_or_descriptor);
114+
file = open(source);
109115
if (sheet) {
110116
rows = await toArray(await file.rows({ sheet }));
111117
} else {

0 commit comments

Comments
 (0)