(python3)
import csv
csvfile = open("filename", 'rt')
contents = csv.reader(csvfile, delimeter=',')
#Read the value of delimiter as a delimiter.
for row in contents:
"""
Even if contents are output as they are, the contents of the file will be
Since it is not output, each line is fetched.
"""
print(row)
For example
The contents of filename
,A,B,C,D,E
1,234,513,25345,5243,52
2,513,52345,523452,5234,45
3,31,5432,54,63,63
If so, If you write the code as below,
import csv
import numpy as np
csvfile = open("filename", 'rt')
contents = csv.reader(csvfile, delimiter=',')
array = np.array( [ row for row in contents ] )
array = array[1:, 1:]
print(array)
The following output result is obtained.
[['234' '513' '25345' '5243' '52']
['513' '52345' '523452' '5234' '45']
['31' '5432' '54' '63' '63']]
Recommended Posts