python Pandas reads an instance of the txt table
- 2020-08-22 22:12:50
- OfStack
Runtime environment
Python 2.7
Operation instance
1. Original text format: space delimited txt, for example
2016-03-22 00:06:24.4463094 Chinese test character
2016-03-22 00:06:32.4565680 You need to edit encoding
2016-03-22 00:06:32.6835965 abc
2016-03-22 00:06:32.8041945 egb
2.pandas reads data
import pandas as pd
data = pd.read_table('Z:/test.txt',header=None,encoding='gb2312',delim_whitespace=True,index_col=0)
#header=None: Not per column column name , you can set it yourself
#encoding='gb2312': Error in other encoding Chinese
#delim_whitespace=True: Use Spaces to separate each line of data
#index_col=0: Set up the first 1 Column data as index