कोर्स में आपका स्वागत है!

Python में डेटा आयात का परिचय

Hugo Bowne-Anderson

Data Scientist at DataCamp

डेटा इम्पोर्ट करें

  • फ्लैट फाइलें, जैसे .txts, .csvs
  • अन्य सॉफ्टवेयर से फाइलें

 

ch_1_1_v2.004.png

Python में डेटा आयात का परिचय

डेटा इम्पोर्ट करें

  • फ्लैट फाइलें, जैसे .txts, .csvs
  • अन्य सॉफ्टवेयर से फाइलें
  • रिलेशनल डेटाबेस

ch_1_1_v2.005.png

Python में डेटा आयात का परिचय

प्लेन टेक्स्ट फाइलें

ch_1_1_v2.007.png

Python में डेटा आयात का परिचय

टेबल डेटा

titanic.csv

                        Name      Sex  Cabin  Survived
     Braund, Mr. Owen Harris     male    NaN         0
  Cumings, Mrs. John Bradley   female    C85         1
      Heikkinen, Miss. Laina   female    NaN         1
Futrelle, Mrs. Jacques Heath   female   C123         1
    Allen, Mr. William Henry     male    NaN         0
1 Source: Kaggle
Python में डेटा आयात का परिचय

टेबल डेटा

titanic.csv

एक पंक्ति हाइलाइट किए हुए titanic.csv

Python में डेटा आयात का परिचय

टेबल डेटा

titanic.csv

एक कॉलम हाइलाइट किए हुए titanic.csv

  • फ्लैट फाइल
Python में डेटा आयात का परिचय

टेक्स्ट फाइल पढ़ना

filename = 'huck_finn.txt'

file = open(filename, mode='r') # 'r' is to read
text = file.read()
file.close()
Python में डेटा आयात का परिचय

टेक्स्ट फाइल प्रिंट करना

print(text)
YOU don't know about me without you have read a book by
the name of The Adventures of Tom Sawyer; but that 
ain't no matter. That book was made by Mr. Mark Twain,
and he told the truth, mainly. There was things which 
he stretched, but mainly he told the truth.  That is 
nothing. never seen anybody but lied one time or 
another, without it was Aunt Polly, or the widow, or 
maybe Mary. Aunt Polly--Tom's Aunt Polly, she is--and
Mary, and the Widow Douglas is all told about in that
book, which is mostly a true book, with some 
stretchers, as I said before.
Python में डेटा आयात का परिचय

फाइल में लिखना

filename = 'huck_finn.txt'
file = open(filename, mode='w')  # 'w' is to write
file.close()
Python में डेटा आयात का परिचय

with के साथ कॉन्टेक्स्ट मैनेजर

with open('huck_finn.txt', 'r') as file:
    print(file.read())
YOU don't know about me without you have read a book by
the name of The Adventures of Tom Sawyer; but that 
ain't no matter. That book was made by Mr. Mark Twain,
and he told the truth, mainly. There was things which 
he stretched, but mainly he told the truth.  That is 
nothing. never seen anybody but lied one time or 
another, without it was Aunt Polly, or the widow, or 
maybe Mary. Aunt Polly--Tom's Aunt Polly, she is--and 
Mary, and the Widow Douglas is all told about in that 
book, which is mostly a true book, with some 
stretchers, as I said before.
Python में डेटा आयात का परिचय

अभ्यासों में, आप:

  • फाइलें कंसोल पर प्रिंट करें
  • खास पंक्तियाँ प्रिंट करें
  • फ्लैट फाइलों पर चर्चा करें
Python में डेटा आयात का परिचय

अभ्यास करते हैं!

Python में डेटा आयात का परिचय

Preparing Video For Download...