Difference between revisions of "Scilab/C4/File-handling/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 1: Line 1:
 
{| Border=1
 
{| Border=1
  
|| Time
+
|| '''Time'''
  
|| Narration
+
|| '''Narration'''
  
 
|-
 
|-
| 00.01
+
| 00:01
 
|Welcome to this spoken tutorial on File Handling using Scilab.  
 
|Welcome to this spoken tutorial on File Handling using Scilab.  
  
 
|-
 
|-
| 00.06.
+
| 00:06.
 
| In this tutorial, we will learn  
 
| In this tutorial, we will learn  
  
 
|-
 
|-
|00.08
+
|00:08
 
|'''File Handling''' with the following functions;  
 
|'''File Handling''' with the following functions;  
  
 
|-
 
|-
|00.11
+
|00:11
 
|'''Write Function'''  
 
|'''Write Function'''  
  
 
|-
 
|-
| 00.12
+
| 00:12
 
|'''Read Function'''  
 
|'''Read Function'''  
  
 
|-
 
|-
|00.14
+
|00:14
 
|'''mopen'''  
 
|'''mopen'''  
  
 
|-
 
|-
|00.15
+
|00:15
 
|'''mclose'''  
 
|'''mclose'''  
  
 
|-
 
|-
| 00.16
+
| 00:16
 
|For Demonstration i am using '''Ubuntu Linux12.04''' operating system with '''Scilab''' version 5.3.3 installed  
 
|For Demonstration i am using '''Ubuntu Linux12.04''' operating system with '''Scilab''' version 5.3.3 installed  
  
 
|-
 
|-
| 00.26
+
| 00:26
 
| You should have Basic knowledge of '''Scilab'''.  
 
| You should have Basic knowledge of '''Scilab'''.  
  
 
|-
 
|-
|00.29
+
|00:29
 
| If not, for relevant spoken tutorials please visit '''spoken hyphen tutorial dot org'''  
 
| If not, for relevant spoken tutorials please visit '''spoken hyphen tutorial dot org'''  
  
 
|-
 
|-
|00.36
+
|00:36
 
|| Now we will see some functions in '''scilab''' which are useful for '''File Handling'''.
 
|| Now we will see some functions in '''scilab''' which are useful for '''File Handling'''.
  
 
|-
 
|-
| 00.41
+
| 00:41
 
|'''File Handling''' involves-  
 
|'''File Handling''' involves-  
  
  
 
|-
 
|-
|00.44
+
|00:44
 
| writing to a file using '''write function''',  
 
| writing to a file using '''write function''',  
  
 
|-
 
|-
  
| 00.47
+
| 00:47
  
 
| reading from a file using '''read function''',  
 
| reading from a file using '''read function''',  
  
 
|-
 
|-
| 00.51
+
| 00:51
 
| opening an existing file using '''mopen function''' and  
 
| opening an existing file using '''mopen function''' and  
  
 
|-
 
|-
| 00.55
+
| 00:55
 
| closing an already opened file using '''mclose function'''.  
 
| closing an already opened file using '''mclose function'''.  
  
 
|-
 
|-
|01.00
+
|01:00
 
| Let us start with writing data to a file.  
 
| Let us start with writing data to a file.  
  
 
|-
 
|-
|01.03
+
|01:03
 
|For this purpose the '''write()''' command is used.  
 
|For this purpose the '''write()''' command is used.  
  
Line 83: Line 83:
 
|-
 
|-
  
|01.07
+
|01:07
  
 
|Switch to the scilab console window.  
 
|Switch to the scilab console window.  
Line 89: Line 89:
 
|-
 
|-
  
|01.10
+
|01:10
  
 
|To begin with let us create a matrix of random numbers.  
 
|To begin with let us create a matrix of random numbers.  
Line 95: Line 95:
 
|-
 
|-
  
| 01.15
+
| 01:15
 
|| Type; ''' random underscore matrix is equal to rand into bracket 20 comma 1 close the bracket semicolon and press enter'''
 
|| Type; ''' random underscore matrix is equal to rand into bracket 20 comma 1 close the bracket semicolon and press enter'''
  
Line 101: Line 101:
 
|-
 
|-
  
| 01.29
+
| 01:29
  
 
| Now check the present working directory.  
 
| Now check the present working directory.  
Line 107: Line 107:
 
|-
 
|-
  
|01.32
+
|01:32
  
 
|| Type  '''pwd '''
 
|| Type  '''pwd '''
Line 114: Line 114:
 
|-
 
|-
  
|01.34
+
|01:34
  
 
| In my case the present working directory is '''slash home slash fossee '''
 
| In my case the present working directory is '''slash home slash fossee '''
Line 120: Line 120:
 
|-
 
|-
  
|01.39
+
|01:39
  
 
| Make sure that you are in a directory where you have read & write permission , before you execute these commands.  
 
| Make sure that you are in a directory where you have read & write permission , before you execute these commands.  
Line 127: Line 127:
 
|-
 
|-
  
|01.47
+
|01:47
  
 
|| Now we will write the content of variable '''random underscore matrix''' into a text file using the write command.  
 
|| Now we will write the content of variable '''random underscore matrix''' into a text file using the write command.  
Line 134: Line 134:
 
|-
 
|-
  
|01.55
+
|01:55
  
 
| Type;--> '''write into bracket into quotes random dash numbers dot txt close  the  quotes comma random underscore matrix close the bracket and press enter'''
 
| Type;--> '''write into bracket into quotes random dash numbers dot txt close  the  quotes comma random underscore matrix close the bracket and press enter'''
Line 140: Line 140:
  
 
|-
 
|-
|02.18
+
|02:18
 
|Let us see whether this file has been created.  
 
|Let us see whether this file has been created.  
  
 
|-
 
|-
| 02.21
+
| 02:21
 
||I will minimize the '''scilab''' console window.  
 
||I will minimize the '''scilab''' console window.  
  
  
 
|-
 
|-
| 02.23
+
| 02:23
 
|And open the file which will be created and saved in the fossee directory of my computer.  
 
|And open the file which will be created and saved in the fossee directory of my computer.  
  
 
|-
 
|-
  
| 02.33
+
| 02:33
 
|| You can see the data from variable '''random underscore matrix is written in a text file random dash numbers dot txt'''
 
|| You can see the data from variable '''random underscore matrix is written in a text file random dash numbers dot txt'''
  
 
|-
 
|-
  
|02.42
+
|02:42
  
 
|| I will close this file.
 
|| I will close this file.
Line 165: Line 165:
 
|-
 
|-
  
|02.45
+
|02:45
  
 
| Coming back to the scilab console.  
 
| Coming back to the scilab console.  
Line 171: Line 171:
 
|-
 
|-
  
|02.47
+
|02:47
  
 
| Now we will see how to read the data from a file.
 
| Now we will see how to read the data from a file.
Line 177: Line 177:
 
|-
 
|-
  
| 02.50
+
| 02:50
 
+
 
|| For this we will use the command read as follows,  
 
|| For this we will use the command read as follows,  
  
 
|-
 
|-
| 02.55
+
| 02:55
 
| Type '''new underscore vector is equal to read into bracket into quote random dash numbers dot txt close the quotes comma 20 comma 1 close the bracket and press enter'''.
 
| Type '''new underscore vector is equal to read into bracket into quote random dash numbers dot txt close the quotes comma 20 comma 1 close the bracket and press enter'''.
  
 
|-
 
|-
|03.18
+
|03:18
 
| The read command reads all the data from the file mentioned in the argument,  
 
| The read command reads all the data from the file mentioned in the argument,  
  
 
|-
 
|-
| 03.23
+
| 03:23
 
| In this case '''random dash numbers dot txt''',
 
| In this case '''random dash numbers dot txt''',
  
 
|-
 
|-
| 03.27
+
| 03:27
 
| And stores in the variable '''new underscore vector'''
 
| And stores in the variable '''new underscore vector'''
  
 
|-
 
|-
| 03.31
+
| 03:31
 
|  Press Enter to continue the display  
 
|  Press Enter to continue the display  
  
 
|-
 
|-
|03.35
+
|03:35
 
| If we modify the above command as  
 
| If we modify the above command as  
  
  
 
|-
 
|-
|03.39
+
|03:39
 
| '''new underscore vector is equal to read into bracket into quote random dash numbers dot txt comma 19 comma 1 '''
 
| '''new underscore vector is equal to read into bracket into quote random dash numbers dot txt comma 19 comma 1 '''
  
 
|-
 
|-
| 03.49
+
| 03:49
 
| The read command reads only 19 data values from the file mentioned in this argument.  
 
| The read command reads only 19 data values from the file mentioned in this argument.  
  
 
|-
 
|-
  
| 03.56
+
| 03:56
  
 
|In this case '''random dash numbers dot txt'''
 
|In this case '''random dash numbers dot txt'''
Line 223: Line 222:
 
|-
 
|-
  
| 03.59
+
| 03:59
 
|| And stores in the variable '''new underscore vector'''.  
 
|| And stores in the variable '''new underscore vector'''.  
  
 
|-
 
|-
  
| 04.03
+
| 04:03
  
 
| |Issue this command on the '''scilab''' console and verify the output.  
 
| |Issue this command on the '''scilab''' console and verify the output.  
Line 235: Line 234:
 
|-
 
|-
  
|04.08
+
|04:08
  
 
||Now let us see about the mopen function:  
 
||Now let us see about the mopen function:  
Line 242: Line 241:
 
|-
 
|-
  
|04.12
+
|04:12
  
 
||'''fd = mopen into bracket file-name comma mode'''
 
||'''fd = mopen into bracket file-name comma mode'''
Line 248: Line 247:
 
|-
 
|-
  
| 04.17
+
| 04:17
  
 
|mopen command is used to open an existing file in a way compatible to C fopen procedure.  
 
|mopen command is used to open an existing file in a way compatible to C fopen procedure.  
Line 255: Line 254:
 
|-
 
|-
  
| 04.25
+
| 04:25
  
 
| mode is a character string that controls whether the file is opened for  
 
| mode is a character string that controls whether the file is opened for  
Line 262: Line 261:
 
|-
 
|-
  
|04.30
+
|04:30
  
 
| r = Opens the file for reading.  
 
| r = Opens the file for reading.  
Line 269: Line 268:
  
 
|-
 
|-
|04.34
+
|04:34
 
| rb = Opens a binary file for reading.  
 
| rb = Opens a binary file for reading.  
  
Line 275: Line 274:
 
|-
 
|-
  
| 04.39
+
| 04:39
  
 
| rt = Opens a text file for reading.  
 
| rt = Opens a text file for reading.  
Line 283: Line 282:
 
|-
 
|-
  
|04.43
+
|04:43
  
 
||w = Creates a new file for writing, or opens and truncates a file to zero length.  
 
||w = Creates a new file for writing, or opens and truncates a file to zero length.  
Line 290: Line 289:
 
|-
 
|-
  
|04.50
+
|04:50
  
 
| wb = Creates a new binary file for writing, or opens and truncates a file to zero length.  
 
| wb = Creates a new binary file for writing, or opens and truncates a file to zero length.  
Line 298: Line 297:
 
|-
 
|-
  
| 04.58
+
| 04:58
  
 
| |wt = Creates a text binary file for writing, or opens and truncates a file to zero length.  
 
| |wt = Creates a text binary file for writing, or opens and truncates a file to zero length.  
Line 306: Line 305:
 
|-
 
|-
  
| 05.06
+
| 05:06
  
 
|a or ab = Appends (opens a file for writing at the end of the file, or creates a file for writing).  
 
|a or ab = Appends (opens a file for writing at the end of the file, or creates a file for writing).  
Line 313: Line 312:
 
|-
 
|-
  
| 05.14
+
| 05:14
  
 
| r+ or r+b = Opens a file for update (reading and writing)  
 
| r+ or r+b = Opens a file for update (reading and writing)  
Line 321: Line 320:
 
|-
 
|-
  
| 05.20
+
| 05:20
  
 
| For eg '''fd underscore r is equal to mopen('random-numbers,'rt')'''
 
| For eg '''fd underscore r is equal to mopen('random-numbers,'rt')'''
Line 329: Line 328:
 
|-
 
|-
  
| 05.30
+
| 05:30
  
 
||the above command opens the 'random-numbers' as a text and read-only mode.  
 
||the above command opens the 'random-numbers' as a text and read-only mode.  
Line 337: Line 336:
 
|-
 
|-
  
| 05.37
+
| 05:37
  
 
||'''mclose into bracket fd''':  
 
||'''mclose into bracket fd''':  
Line 343: Line 342:
 
|-
 
|-
  
| 05.40
+
| 05:40
  
 
|| closes the opened file by using mopen.  
 
|| closes the opened file by using mopen.  
Line 349: Line 348:
 
|-
 
|-
  
| 05.43
+
| 05:43
  
 
|where fd is the file descriptor of the opened file  
 
|where fd is the file descriptor of the opened file  
Line 355: Line 354:
 
|-
 
|-
  
| 05.48
+
| 05:48
  
 
| If fd is omitted mclose closes the last opened file.  
 
| If fd is omitted mclose closes the last opened file.  
Line 361: Line 360:
 
|-
 
|-
  
|05.53
+
|05:53
  
 
|That's all we have in this tutorial.  
 
|That's all we have in this tutorial.  
Line 368: Line 367:
 
|-
 
|-
  
|05.55
+
|05:55
  
 
| We have learnt -  
 
| We have learnt -  
Line 375: Line 374:
 
|-
 
|-
  
| 05.56
+
| 05:56
  
 
| File Handling with the following functions:  
 
| File Handling with the following functions:  
Line 382: Line 381:
 
|-
 
|-
  
|05.59
+
|05:59
  
 
||''' Write Function'''  
 
||''' Write Function'''  
Line 390: Line 389:
 
|-
 
|-
  
| 06.00
+
| 06:00
  
 
| '''Read Function'''  
 
| '''Read Function'''  
Line 397: Line 396:
 
|-
 
|-
  
| 06.02
+
| 06:02
  
 
| '''mopen'''  
 
| '''mopen'''  
Line 405: Line 404:
 
|-
 
|-
  
| 06.03
+
| 06:03
  
 
| '''mclose'''  
 
| '''mclose'''  
Line 412: Line 411:
 
|-
 
|-
  
|06.05
+
|06:05
  
 
| Watch the video available at the following link  
 
| Watch the video available at the following link  
 
|-
 
|-
  
| 06.08
+
| 06:08
  
 
| It summarises the Spoken Tutorial project  
 
| It summarises the Spoken Tutorial project  
Line 425: Line 424:
 
|-
 
|-
  
|06.11
+
|06:11
  
 
||If you do not have good bandwidth, you can download and watch it  
 
||If you do not have good bandwidth, you can download and watch it  
Line 431: Line 430:
 
|-
 
|-
  
|06.14
+
|06:14
  
 
||The spoken tutorial Team
 
||The spoken tutorial Team
Line 437: Line 436:
 
|-
 
|-
  
|06.17
+
|06:17
  
 
||Conducts workshops using spoken tutorials  
 
||Conducts workshops using spoken tutorials  
Line 444: Line 443:
 
|-
 
|-
  
|06.20
+
|06:20
  
 
||Gives certificates to those who pass an online test  
 
||Gives certificates to those who pass an online test  
Line 451: Line 450:
 
|-
 
|-
  
|06.23
+
|06:23
  
 
||For more details, please write to conatct@spoken-tutorial.org  
 
||For more details, please write to conatct@spoken-tutorial.org  
Line 458: Line 457:
 
|-
 
|-
  
|06.30
+
|06:30
  
 
|Spoken Tutorial Project is a part of the Talk to a Teacher project  
 
|Spoken Tutorial Project is a part of the Talk to a Teacher project  
Line 466: Line 465:
 
|-
 
|-
  
| 06.34
+
| 06:34
  
 
| It is supported by the National Mission on Eduction through ICT, MHRD, Government of India.  
 
| It is supported by the National Mission on Eduction through ICT, MHRD, Government of India.  
 
|-
 
|-
  
| 06.41
+
| 06:41
  
 
|More information on this mission is available at  http://spoken-tutorial.org/NMEICT-Intro
 
|More information on this mission is available at  http://spoken-tutorial.org/NMEICT-Intro
Line 477: Line 476:
 
|-
 
|-
  
| 06.50
+
| 06:50
  
 
|This is Anuradha Amrutkar from IIT Bombay signing off.
 
|This is Anuradha Amrutkar from IIT Bombay signing off.
Line 483: Line 482:
 
|-
 
|-
  
|06.54
+
|06:54
  
 
| Thank you for joining.
 
| Thank you for joining.

Revision as of 17:17, 10 July 2014

Time Narration
00:01 Welcome to this spoken tutorial on File Handling using Scilab.
00:06. In this tutorial, we will learn
00:08 File Handling with the following functions;
00:11 Write Function
00:12 Read Function
00:14 mopen
00:15 mclose
00:16 For Demonstration i am using Ubuntu Linux12.04 operating system with Scilab version 5.3.3 installed
00:26 You should have Basic knowledge of Scilab.
00:29 If not, for relevant spoken tutorials please visit spoken hyphen tutorial dot org
00:36 Now we will see some functions in scilab which are useful for File Handling.
00:41 File Handling involves-


00:44 writing to a file using write function,
00:47 reading from a file using read function,
00:51 opening an existing file using mopen function and
00:55 closing an already opened file using mclose function.
01:00 Let us start with writing data to a file.
01:03 For this purpose the write() command is used.


01:07 Switch to the scilab console window.
01:10 To begin with let us create a matrix of random numbers.
01:15 Type; random underscore matrix is equal to rand into bracket 20 comma 1 close the bracket semicolon and press enter


01:29 Now check the present working directory.
01:32 Type pwd


01:34 In my case the present working directory is slash home slash fossee
01:39 Make sure that you are in a directory where you have read & write permission , before you execute these commands.


01:47 Now we will write the content of variable random underscore matrix into a text file using the write command.


01:55 Type;--> write into bracket into quotes random dash numbers dot txt close the quotes comma random underscore matrix close the bracket and press enter


02:18 Let us see whether this file has been created.
02:21 I will minimize the scilab console window.


02:23 And open the file which will be created and saved in the fossee directory of my computer.
02:33 You can see the data from variable random underscore matrix is written in a text file random dash numbers dot txt
02:42 I will close this file.
02:45 Coming back to the scilab console.
02:47 Now we will see how to read the data from a file.
02:50 For this we will use the command read as follows,
02:55 Type new underscore vector is equal to read into bracket into quote random dash numbers dot txt close the quotes comma 20 comma 1 close the bracket and press enter.
03:18 The read command reads all the data from the file mentioned in the argument,
03:23 In this case random dash numbers dot txt,
03:27 And stores in the variable new underscore vector
03:31 Press Enter to continue the display
03:35 If we modify the above command as


03:39 new underscore vector is equal to read into bracket into quote random dash numbers dot txt comma 19 comma 1
03:49 The read command reads only 19 data values from the file mentioned in this argument.
03:56 In this case random dash numbers dot txt


03:59 And stores in the variable new underscore vector.
04:03 Issue this command on the scilab console and verify the output.


04:08 Now let us see about the mopen function:


04:12 fd = mopen into bracket file-name comma mode
04:17 mopen command is used to open an existing file in a way compatible to C fopen procedure.


04:25 mode is a character string that controls whether the file is opened for


04:30 r = Opens the file for reading.


04:34 rb = Opens a binary file for reading.


04:39 rt = Opens a text file for reading.


04:43 w = Creates a new file for writing, or opens and truncates a file to zero length.


04:50 wb = Creates a new binary file for writing, or opens and truncates a file to zero length.


04:58 wt = Creates a text binary file for writing, or opens and truncates a file to zero length.


05:06 a or ab = Appends (opens a file for writing at the end of the file, or creates a file for writing).


05:14 r+ or r+b = Opens a file for update (reading and writing)


05:20 For eg fd underscore r is equal to mopen('random-numbers,'rt')


05:30 the above command opens the 'random-numbers' as a text and read-only mode.


05:37 mclose into bracket fd:
05:40 closes the opened file by using mopen.
05:43 where fd is the file descriptor of the opened file
05:48 If fd is omitted mclose closes the last opened file.
05:53 That's all we have in this tutorial.


05:55 We have learnt -


05:56 File Handling with the following functions:


05:59 Write Function


06:00 Read Function


06:02 mopen


06:03 mclose


06:05 Watch the video available at the following link
06:08 It summarises the Spoken Tutorial project


06:11 If you do not have good bandwidth, you can download and watch it
06:14 The spoken tutorial Team
06:17 Conducts workshops using spoken tutorials


06:20 Gives certificates to those who pass an online test


06:23 For more details, please write to conatct@spoken-tutorial.org


06:30 Spoken Tutorial Project is a part of the Talk to a Teacher project


06:34 It is supported by the National Mission on Eduction through ICT, MHRD, Government of India.
06:41 More information on this mission is available at http://spoken-tutorial.org/NMEICT-Intro
06:50 This is Anuradha Amrutkar from IIT Bombay signing off.
06:54 Thank you for joining.

Contributors and Content Editors

PoojaMoolya, Pratik kamble, Sandhya.np14