This is how to use pandas read_csv. Specify tab delimiter with sep, specify rows to skip to skip to skip.
import pandas as pd
from io import StringIO
text = '' report
content
Number\tName\tGender
1\tHong Gil-dong\tNam
2\tKim Chul-soo\tNam
3\t Lee Younghee\t''
df = pd.read_csv(StringIO(text), sep='\t', skiprows=2)
df = df.set_index ('number')
print(df.head(100))
print('---------gender-------')
print(df['Gender'])
print('---------Name---------')
print(df['name'])
Name Gender
Number
1 Hong Gil Dong Nam
2 Kim Chul-soo Nam
3. Lee Younghee
--------- Gender-------
Number
one son
second son
three women
Name: Gender, dtype: object
--------- Name-----------
Number
1 Hong Gil-dong
2 Kim Chul-soo
3 Lee Younghee
Name: name, dtype: object
© 2024 OneMinuteCode. All rights reserved.