Difference between revisions of "Python/C2/loading-data-from-files/Gujarati"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with '{| border=1 !Visual Cue !Narration |- | 0:01 | Hello Friends and Welcome to this tutorial on "loading data from files". |- | 0:06 | At the end of this tutorial, you will be able…')
 
Line 4: Line 4:
 
|-
 
|-
 
| 0:01
 
| 0:01
| Hello Friends and Welcome to this tutorial on "loading data from files".
+
| નમસ્કાર મિત્રો '''"loading data from files"''' પરનાં આ સ્પોકન ટ્યુટોરીયલમાં સ્વાગત છે.  
  
 
|-
 
|-
 
| 0:06
 
| 0:06
| At the end of this tutorial, you will be able to,
+
| આ ટ્યુટોરીયલની અંતમાં, તમે આપેલ વિશે સમર્થ હશો,
 
+
# Read data from files, containing a single column of data
+
# Read multiple columns of data, separated by spaces or other delimiters.
+
  
 +
૧. ડેટાની એકલ કોલમ ધરાવતી, ફાઈલમાંથી ડેટા વાંચવું
 +
૨. ડેટાની બહુવિધ કોલમને વાંચવું, જે ખાલી જગ્યાથી અથવા બીજા કોઈ વિભાજકોથી જુદી કરાયી હોય.   
 
|-
 
|-
 
| 0:19
 
| 0:19
| Let us switch to the terminal and start IPython, using ipython hypen pylab
+
| '''ipython''' હાયફન '''pylab''' વાપરીને, ચાલો ટર્મિનલ પર જઈએ અને '''IPython''' ચાલુ કરીએ.
  
 
|-
 
|-
 
| 0:33
 
| 0:33
| Now, Let us begin with reading the file primes.txt, which contains a list of prime numbers listed in a column, using the loadtxt command.  
+
| હવે, ચાલો '''loadtxt''' કમાંડ વાપરીને, '''primes.txt''' ફાઈલ વાંચવાથી શરૂઆત કરીએ, જે કોલમમાં યાદીબદ્ધ થયેલ પ્રાથમિક ક્રમાંકોની યાદી ધરાવે છે.      
  
 
|-
 
|-
 
| 0:45
 
| 0:45
|Please make sure that you provide the correct path of the file, 'primes.txt'.  
+
|કૃપા કરી એ વાતની ખાતરી કરી લો કે તમે ''''primes.txt'''', ફાઈલનો યોગ્ય માર્ગ આપ્યો છે.
  
 
|-
 
|-
 
| 0:50
 
| 0:50
|The file, in our case, is presented in  slash home slash fossee slash primes.txt.
+
|ફાઈલ, અમારા કિસ્સામાં, સ્લેશ હોમ સ્લેશ '''fossee''' સ્લેશ '''primes.txt''' માં હાજર છે.  
  
 
|-
 
|-
 
|  0:59
 
|  0:59
| Otherwise we can use the cat command to locate the file and read the contents of it.
+
| અન્યથા આપણે ફાઈલનો પત્તો મેળવવા માટે '''cat''' કમાંડ વાપરી શકીએ છીએ અને તેમાંનાં ઘટકોને વાંચી શકીએ છીએ.  
  
 
|-
 
|-
 
|1:05
 
|1:05
|So type cat slash home slash fossee slash primes.txt
+
|તો ટાઈપ કરો '''cat''' સ્લેશ '''home''' સ્લેશ '''fossee''' સ્લેશ '''primes.txt'''
  
 
|-
 
|-
 
| 1:15
 
| 1:15
| Now let us read this list into the variable primes.
+
|હવે ચાલો વેરીએબલ પ્રાઈમમાંની આ યાદી વાંચીએ.
  
 
|-
 
|-
 
|1:20
 
|1:20
|So type primes = loadtxt within bracket in single quotes slash home slash fossee slash primes.txt  
+
|તો ટાઈપ કરો '''primes = loadtxt''' કૌંસમાં એકલ અવતરણમાં સ્લેશ '''home''' સ્લેશ '''fossee''' સ્લેશ '''primes.txt'''   
  
 
|-
 
|-
 
| 1:41
 
| 1:41
|primes  is now a sequence of prime numbers, that was listed in the file,``primes.txt``.
+
|પ્રાઈમ્સ હવે પ્રાથમિક ક્રમાંકોનો એક અનુક્રમ છે, જે '''``primes.txt``''', ફાઈલમાં યાદીબદ્ધ કરાયેલ હતો.  
  
 
|-
 
|-
 
| 1:49
 
| 1:49
|We now type primes,print primes to see the sequence printed so type print space primes.
+
|આપણે હવે ટાઈપ કરીએ છીએ '''primes,print primes''' એ જોવા માટે કે અનુક્રમ પ્રીંટ થયો છે કે નહી તો ટાઈપ કરો '''print સ્પેસ primes'''.  
  
 
|-
 
|-
 
| 2:00
 
| 2:00
| We observe that all the numbers end with a period.  
+
| આપણે અવલોકન કરીએ છીએ કે તમામ ક્રમાંકો એક અંતર સાથે અંત થાય છે.  
  
 
|-
 
|-
 
| 2:04
 
| 2:04
|This is so, because these numbers are actually read as floats
+
|આ એટલા માટે, કારણ કે આ ક્રમાંકો વાસ્તવમાં ફ્લોટ્સ તરીકે વંચાય છે
  
 
|-
 
|-
 
| 2:10
 
| 2:10
| Now, let us use the loadtxt command to read a file pendulum.txt that contains two columns of data.
+
| હવે, ચાલો આપણે '''pendulum.txt''' ફાઈલને વાંચવા માટે '''loadtxt''' કમાંડનો ઉપયોગ કરીએ જે ડેટાની બે કોલમ ધરાવે છે.      
  
 
|-
 
|-
 
| 2:19
 
| 2:19
| This file contains the length of the pendulum in the first column and the corresponding time period in the second.  
+
|આ ફાઈલ પહેલી કોલમમાં લોલકની લંબાઈ ધરાવે છે અને અનુરૂપ સમયગાળો બીજા કોલમમાં ધરાવે છે.
  
 
|-
 
|-
 
| 2:26
 
| 2:26
| Note that here  loadtxt  needs both the columns to have equal number of rows.
+
| નોંધ લો કે અહીં '''loadtxt''' માટે બંને કોલમ સરખા ક્રમાંકમાં હરોળો ધરાવે એ જરૂરી છે.  
  
 
|-
 
|-
 
| 2:31
 
| 2:31
|We can use the  cat command to view the contents of this file.
+
|આ ફાઈલનાં ઘટકોને જોવા માટે આપણે '''cat''' કમાંડ વાપરી શકીએ છીએ.  
  
 
|-
 
|-
 
| 2:36
 
| 2:36
| So type cat slash home slash fossee slash pendulum.txt  
+
| તો ટાઈપ કરો '''cat''' સ્લેશ '''home''' સ્લેશ '''fossee''' સ્લેશ '''pendulum.txt'''
  
 
|-
 
|-
 
| 2:50
 
| 2:50
| Let us, now, read the data into the variable pend.  
+
| ચાલો હવે, વેરીએબલ '''pend''' માંના ડેટાને વાંચીએ.  
  
 
|-
 
|-
 
| 2:55
 
| 2:55
|Again, it is assumed that the file is in  slash home slash fossee  
+
|ફરીથી, તે ધારે છે કે ફાઈલ સ્લેશ '''home''' સ્લેશ '''fossee''' માં છે
  
 
|-
 
|-
 
| 3:02
 
| 3:02
|So type pend = loadtxt within bracket in single quote slash home slash fossee slash pendulum.txt  
+
|તો ટાઈપ કરો '''pend = loadtxt''' કૌંસમાં એકલ અવતરણમાં સ્લેશ '''home''' સ્લેશ '''fossee''' સ્લેશ '''pendulum.txt'''
  
 
|-
 
|-
 
|  3:21
 
|  3:21
| Let us now print the variable  pend and see what it contains.
+
| ચાલો આપણે હવે વેરીએબલ '''pend''' ને પ્રીંટ કરીએ અને જોઈએ તે શું ધરાવે છે.
  
 
|-
 
|-
 
|3:26
 
|3:26
|So type print pend  
+
|તો ટાઈપ કરો '''print pend'''
  
 
|-
 
|-
 
|  3:31
 
|  3:31
| Notice that  pend is not a simple sequence like  primes .  
+
| નોંધ લો કે '''pend''' એ '''primes''' ની જેમ સાદો અનુક્રમ નથી.  
  
 
|-
 
|-
 
| 3:35
 
| 3:35
|It has two sequences, containing both the columns of the data file.
+
|તે બે અનુક્રમ ધરાવે છે, ડેટા ફાઈલની બંને કોલમોનો સમાવેશ કરીને.
  
 
|-
 
|-
 
| 3:40
 
| 3:40
| Let us use an additional argument of the  load txt command, to read it into two separate, simple sequences.
+
| તેને બે જુદા, સામાન્ય અનુક્રમમાં વાંચવા માટે, ચાલો '''load txt''' કમાંડની વધારાની આર્ગ્યુંમેંટનો ઉપયોગ કરીએ.
  
 
|-
 
|-
 
|3:50
 
|3:50
|So type L, T space = space load txt within bracket single quote slash home slash fossee slash pendulum.txt comma unpack=True
+
|તો ટાઈપ કરો '''L, T space = space load txt''' કૌંસમાં એકલ અવતરણમાં સ્લેશ '''home''' સ્લેશ '''fossee''' સ્લેશ '''pendulum.txt''' અલ્પવિરામ '''unpack=True'''
  
 
|-
 
|-
 
| 4:23
 
| 4:23
| Let us now, print the variables L and T, to see what they contain.
+
|ચાલો આપણે હવે, વેરીએબલ ''''L અને T'' ને પ્રીંટ કરીએ, એ જોવા માટે કે એ શું ધરાવે છે.
  
 
|-
 
|-
 
|4:29
 
|4:29
|So type print space L
+
|તો ટાઈપ કરો '''print space L'''
print space T
+
 
 +
'''print space T'''
  
 
|-
 
|-
 
| 4:39
 
| 4:39
| Notice, that L and T now contain the first and second columns of data from the data file, pendulum.txt, and they are both simple sequences.
+
| નોંધ લો, કે '''L અને T''' હવે '''pendulum.txt''', ડેટા ફાઈલમાંથી પહેલી અને બીજી ડેટાની કોલમો ધરાવે છે, અને તે બંને સાદા અનુક્રમ છે.      
  
 
|-
 
|-
 
| 4:50
 
| 4:50
|unpack=True has given us the two columns into two separate sequences instead of one complex sequence.
+
|'''unpack=True''' આપણને બે કોલમો એક જટિલ અનુક્રમનાં બદલે બે જુદા જુદા અનુક્રમમાં આપી છે.
  
 
|-
 
|-
 
|  5:00
 
|  5:00
| Till now, we have learnt the basic use of the load txt command.
+
|હમણાં સુધી, આપણે '''load txt''' કમાંડનો સામાન્ય ઉપયોગ શીખ્યા છીએ.  
  
 
|-
 
|-
 
| 5:05
 
| 5:05
| Let us try an example.
+
|ચાલો એક ઉદાહરણ પ્રયાસ કરીએ.
  
 
|-
 
|-

Revision as of 16:54, 11 October 2013

Visual Cue Narration
0:01 નમસ્કાર મિત્રો "loading data from files" પરનાં આ સ્પોકન ટ્યુટોરીયલમાં સ્વાગત છે.
0:06 આ ટ્યુટોરીયલની અંતમાં, તમે આપેલ વિશે સમર્થ હશો,

૧. ડેટાની એકલ કોલમ ધરાવતી, ફાઈલમાંથી ડેટા વાંચવું ૨. ડેટાની બહુવિધ કોલમને વાંચવું, જે ખાલી જગ્યાથી અથવા બીજા કોઈ વિભાજકોથી જુદી કરાયી હોય.

0:19 ipython હાયફન pylab વાપરીને, ચાલો ટર્મિનલ પર જઈએ અને IPython ચાલુ કરીએ.
0:33 હવે, ચાલો loadtxt કમાંડ વાપરીને, primes.txt ફાઈલ વાંચવાથી શરૂઆત કરીએ, જે કોલમમાં યાદીબદ્ધ થયેલ પ્રાથમિક ક્રમાંકોની યાદી ધરાવે છે.
0:45 કૃપા કરી એ વાતની ખાતરી કરી લો કે તમે 'primes.txt', ફાઈલનો યોગ્ય માર્ગ આપ્યો છે.
0:50 ફાઈલ, અમારા કિસ્સામાં, સ્લેશ હોમ સ્લેશ fossee સ્લેશ primes.txt માં હાજર છે.
0:59 અન્યથા આપણે ફાઈલનો પત્તો મેળવવા માટે cat કમાંડ વાપરી શકીએ છીએ અને તેમાંનાં ઘટકોને વાંચી શકીએ છીએ.
1:05 તો ટાઈપ કરો cat સ્લેશ home સ્લેશ fossee સ્લેશ primes.txt
1:15 હવે ચાલો વેરીએબલ પ્રાઈમમાંની આ યાદી વાંચીએ.
1:20 તો ટાઈપ કરો primes = loadtxt કૌંસમાં એકલ અવતરણમાં સ્લેશ home સ્લેશ fossee સ્લેશ primes.txt
1:41 પ્રાઈમ્સ હવે પ્રાથમિક ક્રમાંકોનો એક અનુક્રમ છે, જે ``primes.txt``, ફાઈલમાં યાદીબદ્ધ કરાયેલ હતો.
1:49 આપણે હવે ટાઈપ કરીએ છીએ primes,print primes એ જોવા માટે કે અનુક્રમ પ્રીંટ થયો છે કે નહી તો ટાઈપ કરો print સ્પેસ primes.
2:00 આપણે અવલોકન કરીએ છીએ કે તમામ ક્રમાંકો એક અંતર સાથે અંત થાય છે.
2:04 આ એટલા માટે, કારણ કે આ ક્રમાંકો વાસ્તવમાં ફ્લોટ્સ તરીકે વંચાય છે
2:10 હવે, ચાલો આપણે pendulum.txt ફાઈલને વાંચવા માટે loadtxt કમાંડનો ઉપયોગ કરીએ જે ડેટાની બે કોલમ ધરાવે છે.
2:19 આ ફાઈલ પહેલી કોલમમાં લોલકની લંબાઈ ધરાવે છે અને અનુરૂપ સમયગાળો બીજા કોલમમાં ધરાવે છે.
2:26 નોંધ લો કે અહીં loadtxt માટે બંને કોલમ સરખા ક્રમાંકમાં હરોળો ધરાવે એ જરૂરી છે.
2:31 આ ફાઈલનાં ઘટકોને જોવા માટે આપણે cat કમાંડ વાપરી શકીએ છીએ.
2:36 તો ટાઈપ કરો cat સ્લેશ home સ્લેશ fossee સ્લેશ pendulum.txt
2:50 ચાલો હવે, વેરીએબલ pend માંના ડેટાને વાંચીએ.
2:55 ફરીથી, તે ધારે છે કે ફાઈલ સ્લેશ home સ્લેશ fossee માં છે
3:02 તો ટાઈપ કરો pend = loadtxt કૌંસમાં એકલ અવતરણમાં સ્લેશ home સ્લેશ fossee સ્લેશ pendulum.txt
3:21 ચાલો આપણે હવે વેરીએબલ pend ને પ્રીંટ કરીએ અને જોઈએ તે શું ધરાવે છે.
3:26 તો ટાઈપ કરો print pend
3:31 નોંધ લો કે pendprimes ની જેમ સાદો અનુક્રમ નથી.
3:35 તે બે અનુક્રમ ધરાવે છે, ડેટા ફાઈલની બંને કોલમોનો સમાવેશ કરીને.
3:40 તેને બે જુદા, સામાન્ય અનુક્રમમાં વાંચવા માટે, ચાલો load txt કમાંડની વધારાની આર્ગ્યુંમેંટનો ઉપયોગ કરીએ.
3:50 તો ટાઈપ કરો L, T space = space load txt કૌંસમાં એકલ અવતરણમાં સ્લેશ home સ્લેશ fossee સ્લેશ pendulum.txt અલ્પવિરામ unpack=True
4:23 ચાલો આપણે હવે, વેરીએબલ ''L અને T ને પ્રીંટ કરીએ, એ જોવા માટે કે એ શું ધરાવે છે.
4:29 તો ટાઈપ કરો print space L

print space T

4:39 નોંધ લો, કે L અને T હવે pendulum.txt, ડેટા ફાઈલમાંથી પહેલી અને બીજી ડેટાની કોલમો ધરાવે છે, અને તે બંને સાદા અનુક્રમ છે.
4:50 unpack=True આપણને બે કોલમો એક જટિલ અનુક્રમનાં બદલે બે જુદા જુદા અનુક્રમમાં આપી છે.
5:00 હમણાં સુધી, આપણે load txt કમાંડનો સામાન્ય ઉપયોગ શીખ્યા છીએ.
5:05 ચાલો એક ઉદાહરણ પ્રયાસ કરીએ.
5:07 Pause the video here, try out the following exercise and resume the video.
5:12 Read the file pendulum underscore semicolon.txt which contains the same data as pendulum.txt, but the columns are separated by semi-colons instead of spaces.
5:27 Use the IPython help to see how to do this.
5:34 Switch back to the terminal

L comma T = loadtxt within bracket in single quote slash home slash fossee slash pendulum underscore semicolon.txt comma unpack=True comma

              delimiter=semi-colon within single quote
6:54 Okay then type print L
6:40 print T
6:45 This brings us to the end of this tutorial.
6:48 In this tutorial, we have learnt to,
6:51 1. To Read data from files, containing a single column of data using the loadtxt command.
6:58 2. To Read multiple columns of data, separated by spaces or other delimiters.
7:04 Here are some self assessment questions for you to solve

1. loadtxt can read data from a file with one column only. True or False?

7:18 2. Given a file data.txt with three columns of data separated by spaces, read it into 3 separate simple sequences.
7:29 3. Given a file data.txt with three columns of data separated by ":", read it into 3 separate simple sequences.
7:45 And now the answers,1. False.
7:50 loadtxt command can read data from files having both single columns as well as multiple columns.
7:58 2. A file with three columns of data separated by spaces to be read into 3 separate sequences, we use the loadtxt command as, x = loadtxt within bracket in double quotes data.txt comma unpack=True
8:19 3. If a file with three columns of data separated by delimiters,we read it into three separate sequences by using an additional argument of delimiter in the loadtxt command

x = loadtxt within bracket in double quotes data.txt comma unpack=True comma delimiter=in double quotes semicolon)

8:51 Hope you have enjoyed this tutorial and found it useful.
8:55 Thank you!

Contributors and Content Editors

Jyotisolanki