TXT text files can store all kinds of data, structured two-dimensional tables, semi-structured JSON, unstructured pure text.

Two-dimensional tables stored in Excel and CSV files can be directly stored in TXT files.



Semi-structured JSON can also be stored in TXT text files.



The most common is a TXT file that stores a bunch of unstructured data:

Read json semi-structured data from TXT

import pandas as pd import json f = open(".. /data/test.txt","r",encoding="utf-8") data = json.load(f)Copy the code

So what is the data type of data?

print(type(data))
Copy the code

Dict If you don’t know dict from JSON, take a look at my article

What is JSON?

Since we read a dict variable, we access the result as a dict key-value.

👏👏👏 take a look at our previous article 😃😃😃 🌺 Excel data analysis tool library – correlation coefficient 🌺 dry goods, hand in hand to teach you to do correlation analysis 🌺 5 years of data analysis road, summary. 🌺 user segmentation and portrait analysis 🌺 K-nearest neighbor algorithm and practice

Welcome to our wechat official account.Home of data analysts

Scan the QR code to follow us

💁 provides career planning, resume guidance, interview counseling services

QQ communication group: 254674155