danfo.read_excel

Reads an excel file into DataFrame.

danfo.read_excel(source, configs) [source]

Parameters

Type

Description

source

string

source : string, URL or local file path to retreive Excel file.

configs

Object

{

sheet : string, (Optional) Name of the sheet which u want to parse. Default will be the first sheet.

header_index : int, (Optional) Only used in browser environment. The Index of the row which represents the header(columns) of the data. Default will be the first non empty row.

data_index : int, (Optional) Only used in browser environment. The index of the row from which actual data(content) starts. Default will be the next row of header_index

}

Returns:

return {Promise} DataFrame structure of parsed Excel data

Example

The read_excel method can read excel files saved from local disk, or over the internet.

Node.js
Browser
Node.js
const dfd = require("danfojs-node")
local_xcel = 'testexcel.xls'
async function load_process_data() {
let df = await dfd.read_excel(local_xcel)
df.head().print()
}
load_process_data()
Browser
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/bundle.min.js"></script>
<title>Document</title>
</head>
<body>
<script>
const remote_url = 'https://file-examples-com.github.io/uploads/2017/02/file_example_XLS_100.xls';
dfd.read_excel(remote_url).then(df => {
df.head().print()
})
</script>
</body>
</html>