How to Read and Write CSV, JSON and Text Files in Python (with open and with)
Ravindra Bagale's Tip — Chala mitrano
Data lives in files: CSV exports, JSON from apps, plain text logs. Today we read and write all three with plain Python, so you know what pandas read_csv does for you.
Ravindra Bagale's Tip – चला मित्रांनो
Data files मध्ये असतो: CSV exports, apps मधला JSON, साधे text logs. आज साध्या Python ने तिन्ही वाचू आणि लिहू, म्हणजे pandas read_csv तुमच्यासाठी काय करतो ते समजेल.
Ravindra Bagale's Tip – चलो दोस्तों
Data files में रहता है: CSV exports, apps से JSON, सादे text logs. आज सादे Python से तीनों पढ़ेंगे और लिखेंगे, ताकि समझ आए कि pandas read_csv आपके लिए क्या करता है.
What you will learn in this chapter
- File paths and the working folder
- Read and write text files with open() and with
- Read a CSV with the csv module
- Write a CSV
- Read and write JSON
- Common file errors and encoding
Practice data
All names, shops, banks, hospitals and amounts in this chapter are made up for learning. They are not real people or real company numbers.