Python Data Products
Python Data Products
Course 1: Basics
Lecture: Reading CSV and JSON into Python
Learning objectives
In this lecture we will... ? Demonstrate the main methods to read CSV/TSV
and JSON files in Python ? Understand some of the edge cases that make
reading these formats difficult
Python Data Products Specialization: Course 1: Basic Data Processing...
CSV/TSV in Python
In this lecture we'll look through a few functions to read CSV/TSV and JSON
data in Python:
? string.split() ? csv.reader (library) ? eval() and ast.eval() ? json.loads (library)
Python Data Products Specialization: Course 1: Basic Data Processing...
Code: String.split()
Note: preserves whitespace!
? Converts a string to a list, given a separator ? By default, any whitespace separator is used (tab, space,
newline) ? But different separators can be provided via an optional
argument
Python Data Products Specialization: Course 1: Basic Data Processing...
Code: String.split()
What happens when the delimiter appears in the column?
Note: splits into three columns rather than two!
? This could be addressed by using a different delimiter (e.g. ';'), though this doesn't generalize for fields containing arbitrary text
? Normally, the field will be escaped by quotes
Python Data Products Specialization: Course 1: Basic Data Processing...
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- python data frame append
- python data frame group by
- python data type definition
- python data frame column type
- python data visualization packages
- python data type of variable
- python data science tutorial
- export python data to csv
- python data encryption
- python data array
- python data distribution plot
- python data frame