Skip to content

Commit 69907c4

Browse files
committed
build with webpack
1 parent 61912c6 commit 69907c4

16 files changed

Lines changed: 109 additions & 32898 deletions

File tree

browser-dist/main.js

Lines changed: 0 additions & 29527 deletions
This file was deleted.

danfojs/src/core/generic.js

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as tf from '@tensorflow/tfjs'
33
import { table } from 'table'
44
import { Utils } from './utils'
55
import { Configs } from '../config/config'
6-
import { createArrayCsvWriter, createArrayCsvStringifier } from 'csv-writer'
6+
// import { createArrayCsvWriter, createArrayCsvStringifier } from 'csv-writer'
77
// const createCsvWriter = require('csv-writer').createObjectCsvWriter;
88
// const createCsvStringifier = require('csv-writer').createObjectCsvStringifier;
99

@@ -326,38 +326,38 @@ export default class NDframe {
326326
* Write object to a comma-separated values (csv) file.
327327
* @params {path} File path or object, if None is provided the result is returned as a string
328328
*/
329-
async to_csv(path = "") {
330-
let records = this.values
331-
332-
if (path == "" || path == undefined) {
333-
//return string version of CSV
334-
const csvStringifier = createArrayCsvStringifier({
335-
header: this.column_names
336-
});
337-
let head = csvStringifier.getHeaderString()
338-
let csv_string = csvStringifier.stringifyRecords(records)
339-
let file = `${head}${csv_string}`
340-
return file
341-
342-
} else {
343-
//save to path and return path uri of CSV
344-
const csvWriter = createArrayCsvWriter({
345-
header: this.column_names,
346-
path: path
347-
});
348-
349-
csvWriter.writeRecords(records)
350-
.then(() => {
351-
console.log(`CSV file saved in ${path}`)
352-
return path
353-
}).catch((err) => {
354-
throw Error(err)
355-
})
356-
}
329+
// async to_csv(path = "") {
330+
// let records = this.values
331+
332+
// if (path == "" || path == undefined) {
333+
// //return string version of CSV
334+
// const csvStringifier = createArrayCsvStringifier({
335+
// header: this.column_names
336+
// });
337+
// let head = csvStringifier.getHeaderString()
338+
// let csv_string = csvStringifier.stringifyRecords(records)
339+
// let file = `${head}${csv_string}`
340+
// return file
341+
342+
// } else {
343+
// //save to path and return path uri of CSV
344+
// const csvWriter = createArrayCsvWriter({
345+
// header: this.column_names,
346+
// path: path
347+
// });
348+
349+
// csvWriter.writeRecords(records)
350+
// .then(() => {
351+
// console.log(`CSV file saved in ${path}`)
352+
// return path
353+
// }).catch((err) => {
354+
// throw Error(err)
355+
// })
356+
// }
357357

358358

359359

360-
}
360+
// }
361361

362362
// /**
363363
// * Write object to a JSON Format (csv) file.

danfojs/src/io/reader.js

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DataFrame } from '../core/frame'
22
import * as tf from '@tensorflow/tfjs'
3-
import fetch from "node-fetch"
4-
import fs from 'fs'
3+
// import fetch from "node-fetch"
4+
// import fs from 'fs'
55

66

77
// import * as tf from '@tensorflow/tfjs'
@@ -29,42 +29,42 @@ export const read_csv = async (source,chunk) => {
2929
}
3030

3131

32-
/**
33-
* Reads a JSON file from local or remote address
34-
*
35-
* @param {source} URL or local file path to retreive JSON file.
36-
* @returns {Promise} DataFrame structure of parsed CSV data
37-
*/
38-
export const read_json = async (source) => {
39-
if (source.startsWith("http")) {
40-
//reading from the internet
41-
fetch(source, { method: "Get" })
42-
.then(res => res.json())
43-
.then((json) => {
44-
let df = new DataFrame(json)
45-
return df
46-
}).catch((err) => {
47-
throw Error(err)
48-
})
49-
} else {
50-
//reading from local path
51-
fs.readFile(source, (err, fileData) => {
52-
if (err) {
53-
throw Error(err)
54-
}
55-
try {
56-
const object = JSON.parse(fileData)
57-
let df = new DataFrame(object)
58-
return df
59-
} catch (err) {
60-
throw Error(err)
61-
}
62-
})
63-
64-
65-
}
32+
// /**
33+
// * Reads a JSON file from local or remote address
34+
// *
35+
// * @param {source} URL or local file path to retreive JSON file.
36+
// * @returns {Promise} DataFrame structure of parsed CSV data
37+
// */
38+
// export const read_json = async (source) => {
39+
// if (source.startsWith("http")) {
40+
// //reading from the internet
41+
// fetch(source, { method: "Get" })
42+
// .then(res => res.json())
43+
// .then((json) => {
44+
// let df = new DataFrame(json)
45+
// return df
46+
// }).catch((err) => {
47+
// throw Error(err)
48+
// })
49+
// } else {
50+
// //reading from local path
51+
// fs.readFile(source, (err, fileData) => {
52+
// if (err) {
53+
// throw Error(err)
54+
// }
55+
// try {
56+
// const object = JSON.parse(fileData)
57+
// let df = new DataFrame(object)
58+
// return df
59+
// } catch (err) {
60+
// throw Error(err)
61+
// }
62+
// })
63+
64+
65+
// }
6666

67-
}
67+
// }
6868

6969

7070
// /**

danfojs/tests/core/generic.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -216,22 +216,22 @@ describe("Generic (NDFrame)", function () {
216216
})
217217
})
218218

219-
describe("to_csv", async function () {
220-
it("Converts DataFrame of Series to csv format and return path", async function () {
221-
let data = [{ alpha: "A", count: 1 }, { alpha: "B", count: 2 }, { alpha: "C", count: 3 }]
222-
let df = new NDframe(data)
223-
let dpath = '/Users/mac/Documents/Opensource/danfojs/temp-out/file.csv'
224-
df.to_csv(dpath).then((return_path)=>{
225-
assert.deepEqual(return_path, dpath)
226-
})
227-
})
228-
it("Converts DataFrame of Series to csv format and return string when path is not specified", async function () {
229-
let data = [[12, 2, 20], [90, 5, 23], [45, 56, 70], [9, 10, 19]]
230-
let df = new NDframe(data, {columns: ["A", "B", "C"]})
231-
let result = `A,B,C\n12,2,20\n90,5,23\n45,56,70\n9,10,19\n`
232-
assert.deepEqual(await df.to_csv(), result)
233-
})
234-
})
219+
// describe("to_csv", async function () {
220+
// it("Converts DataFrame of Series to csv format and return path", async function () {
221+
// let data = [{ alpha: "A", count: 1 }, { alpha: "B", count: 2 }, { alpha: "C", count: 3 }]
222+
// let df = new NDframe(data)
223+
// let dpath = '/Users/mac/Documents/Opensource/danfojs/temp-out/file.csv'
224+
// df.to_csv(dpath).then((return_path)=>{
225+
// assert.deepEqual(return_path, dpath)
226+
// })
227+
// })
228+
// it("Converts DataFrame of Series to csv format and return string when path is not specified", async function () {
229+
// let data = [[12, 2, 20], [90, 5, 23], [45, 56, 70], [9, 10, 19]]
230+
// let df = new NDframe(data, {columns: ["A", "B", "C"]})
231+
// let result = `A,B,C\n12,2,20\n90,5,23\n45,56,70\n9,10,19\n`
232+
// assert.deepEqual(await df.to_csv(), result)
233+
// })
234+
// })
235235

236236

237237
})

danfojs/tests/io/reader.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ import { read_csv, read_json } from '../../src/io/reader';
2626
// })
2727
// })
2828

29-
describe("read_json", async function () {
30-
it("reads a json file from local file path", async function () {
31-
const json_path = '/Users/mac/Documents/Opensource/web_book_data.json'
32-
33-
read_json(json_path).then((df) => {
34-
const columns = df.column_names
35-
assert.deepEqual(columns, ["book_id", "title", "image_url", "authors"])
36-
assert.equal(df.shape[1], 4)
37-
}).catch((err) => {
38-
console.log(err);
39-
})
40-
})
29+
// describe("read_json", async function () {
30+
// it("reads a json file from local file path", async function () {
31+
// const json_path = '/Users/mac/Documents/Opensource/web_book_data.json'
32+
33+
// read_json(json_path).then((df) => {
34+
// const columns = df.column_names
35+
// assert.deepEqual(columns, ["book_id", "title", "image_url", "authors"])
36+
// assert.equal(df.shape[1], 4)
37+
// }).catch((err) => {
38+
// console.log(err);
39+
// })
40+
// })
4141

4242
// it("reads a json file over the internet", async function () {
4343
// const jsonUrl =
@@ -52,6 +52,6 @@ describe("read_json", async function () {
5252
// })
5353

5454
// })
55-
})
55+
// })
5656

5757

0 commit comments

Comments
 (0)