1
00:00:01,480 --> 00:00:02,080
Hi everyone.

2
00:00:02,080 --> 00:00:06,680
So in this lesson we will write the code for rating data from a file.

3
00:00:06,820 --> 00:00:08,710
So let's jump directly into code.

4
00:00:09,760 --> 00:00:14,280
So this is my file the name of the file is reading from a file guard CPB.

5
00:00:14,470 --> 00:00:19,960
And this is the folder this containing to file my file would be and read from a file or CBP.

6
00:00:19,960 --> 00:00:24,810
So this is my file my failure to steal it does open this file so it does contain a lot of data.

7
00:00:24,820 --> 00:00:26,380
So let us remove some data

8
00:00:29,720 --> 00:00:32,560
so in all this is the content of the file first string.

9
00:00:32,640 --> 00:00:35,980
The second one is indeed the value and the third one is also a string.

10
00:00:36,000 --> 00:00:44,560
So let's remember now the string in the string so first of all I have to include the file stream fine

11
00:00:44,560 --> 00:00:49,300
stream.

12
00:00:49,340 --> 00:00:52,550
So now we will use the class input file stream.

13
00:00:52,550 --> 00:00:58,110
So I f stream you want to create this object ISIS is the name of the object.

14
00:00:58,520 --> 00:01:01,910
So there's two ways to open the file first is using the constructor.

15
00:01:01,910 --> 00:01:03,270
So my file dot the x.

16
00:01:03,290 --> 00:01:08,750
So this file already exists because we created this file in our last session.

17
00:01:08,780 --> 00:01:11,850
So now we know that first value is actually a string.

18
00:01:11,900 --> 00:01:15,850
So String name second is actually that all number that is in danger.

19
00:01:15,950 --> 00:01:19,460
And the third one is actually a string string.

20
00:01:19,520 --> 00:01:20,450
Basically branch

21
00:01:23,680 --> 00:01:24,550
now taken input.

22
00:01:24,580 --> 00:01:31,090
So I office take name as input then take rule number as input.

23
00:01:31,090 --> 00:01:34,060
Then take branch as input.

24
00:01:34,090 --> 00:01:38,560
So I'm taking the input and after digging the input let us sprint the content.

25
00:01:38,560 --> 00:01:40,160
What is the content.

26
00:01:40,240 --> 00:01:41,050
So we'll see out

27
00:01:43,900 --> 00:01:45,620
first of all what is the name of the student

28
00:01:48,770 --> 00:01:50,690
so after the name that does spring.

29
00:01:50,690 --> 00:01:51,890
Do you remember of the student

30
00:01:56,360 --> 00:02:01,660
and after William but not at the Sprint the branch of the student

31
00:02:14,760 --> 00:02:16,340
so their desks are in our file.

32
00:02:16,370 --> 00:02:17,160
That's another called

33
00:02:19,920 --> 00:02:24,360
so the name is less net row number is today and the branches CSC.

34
00:02:24,900 --> 00:02:27,240
So our code is working correctly.

35
00:02:27,570 --> 00:02:34,600
Now I told you so instead of using the constructor you can do so instead of constructor.

36
00:02:34,600 --> 00:02:36,910
I also have the function open.

37
00:02:36,910 --> 00:02:39,260
So let us use that open function.

38
00:02:39,340 --> 00:02:46,720
So if the stream I office I if it's not open you can give the file name.

39
00:02:46,900 --> 00:02:50,230
So this is the name of the file is my file not the 60

40
00:02:54,030 --> 00:02:55,350
so this will also work fine.

41
00:02:55,350 --> 00:02:55,890
So let's see

42
00:02:58,680 --> 00:03:01,510
solver code is working.

43
00:03:01,610 --> 00:03:07,440
Now I told you you have functions like what you can do you can check with that file exist or not.

44
00:03:07,790 --> 00:03:09,200
So you can write like this.

45
00:03:09,230 --> 00:03:15,020
So if the file exist then you can say the file is opened

46
00:03:18,940 --> 00:03:26,710
fighters opened or you can write file exist so let's test this called

47
00:03:29,490 --> 00:03:30,870
So the file is open.

48
00:03:30,870 --> 00:03:31,900
So this is working.

49
00:03:31,950 --> 00:03:42,560
And the second function was is open function so you can also write this also IFRS Dart is unless code

50
00:03:42,560 --> 00:03:47,170
open and you can print the same thing here

51
00:03:51,490 --> 00:03:52,510
so file is opened

52
00:03:57,310 --> 00:04:00,280
so file is open is getting printed two times.

53
00:04:00,280 --> 00:04:01,680
Correct.

54
00:04:01,690 --> 00:04:07,020
Now one important thing that I'm missing here is after doing all the work we have to close the file.

55
00:04:07,090 --> 00:04:09,610
So my book of the file finishes here.

56
00:04:09,610 --> 00:04:12,120
So let's close the connection.

57
00:04:12,430 --> 00:04:17,890
So if it's not closed function OK.

58
00:04:17,900 --> 00:04:19,100
So this is important.

59
00:04:19,100 --> 00:04:20,900
You have to close the connection.

60
00:04:21,170 --> 00:04:25,830
So let's see so our code is working.

61
00:04:25,830 --> 00:04:26,910
Hundred percent correct.

62
00:04:27,660 --> 00:04:30,530
So this is all about reading from a file.

63
00:04:30,630 --> 00:04:33,760
So in the next review we will discuss about civilization.

64
00:04:33,990 --> 00:04:36,190
So I will see you in the next video by.
