0:00
uh hello guys uh welcome to this video
0:02
So in this video I will show you how to
0:04
convert uh this Excel file which is
0:08
Microsoft Excel file into JSON file
0:11
inside NodeJS So we will actually write
0:14
a very simple script which will convert
0:16
the data which is contained inside your
0:18
Excel file inside our terminal So you
0:22
can see if I open this Excel file this
0:24
data looks something like this We have a
0:27
set of columns right here set of rows
0:30
out there So we will convert all this
0:33
data of this Microsoft Excel file to a
0:35
JSON file here And if I run this
0:40
script just see as I run the script here
0:43
on the left hand side this Excel file
0:45
will be converted and Excel to JSON
0:48
conversion complete and you will
0:50
actually see it's on the left hand side
0:52
a JSON file has been created and if I
0:54
open this file right here you will see
0:56
an array of JSON objects will be created
0:59
Each object you can see has these
1:02
properties This is a second object
1:05
So in this easy way So let me just get
1:08
started here How I build this So first
1:11
of all we need this third party package
1:14
which will be coming from this uh XLS
1:18
package So we just need to install this
1:20
package here So just go to your command
1:23
line just install this third party
1:25
package by this command here I've
1:28
already installed it So you need this
1:31
package and then you also need the file
1:34
system package which is a built-in
1:36
package inside your NodeJS application
1:39
So we actually required this After that
1:44
say the input file here So this contains
1:48
a function called as read file and here
1:50
you will actually pass the input file
1:52
name which is contained inside the same
1:54
directory So output.xls So we will
1:57
actually pass this input file here which
2:03
be after passing the name we will get
2:06
access to the sheet So whatever is the
2:09
sheet here So we can easily call this
2:11
function workbook sheet
2:16
names and we will get access to the
2:18
first sheet As you know that in Excel
2:20
file there are multiple sheets So we are
2:23
getting access to this first sheet
2:25
number sheet one So we are simply
2:28
passing the name right here We will get
2:30
access to the sheet one and after that
2:33
we will get access to the data So
2:36
whatever data is available we can
2:38
actually call this function XLS utils
2:41
dot sheet to JSON So there is this
2:45
function out there which allows you to
2:47
export all the data inside a JSON file
2:53
specify the workbook So workbook dot
2:57
sheets and here you need to provide the
3:00
sheet name So after providing it we will
3:04
basically write this file So there is a
3:08
function right there file system.right
3:10
Write file synchronous and here you will
3:13
specify the file name which will be
3:15
output JSON and then you will specify
3:18
convert all the data JSON.t stringy file
3:26
2 So then we can actually show a
3:28
notification that uh Excel file
3:31
converted to JSON successfully So in
3:34
this easy way guys you can
3:36
actually convert your Excel file into
3:39
JSON And uh now let's suppose I delete
3:44
here before running your application So
3:47
now you will see there are no file
3:50
present If I run the application now
3:53
node index.js you will see this
3:55
notification and this JSON file is
4:00
And if you see you will see your output
4:04
JSON file will be created which will
4:07
hold this array of object Each object
4:09
which is contained inside each data
4:12
inside your Excel file has been
4:13
converted inside your JSON file So all
4:16
the source code guys is given in the
4:18
description of this video and uh also
4:23
freemediattools.com which contains
4:25
thousands of tools regarding audio video