I'm a very beginning programmer. I've been trying to figure this out for a few days but can't seem to wrap my head around it.
I am working with txt files (they are generated by another program). The columns contain no titles (headers?). Values are seperated by tabs.
This is the base file:
Boom IFG : telefonische contactname (D+3) 13
Hemiksem IFG : bureelgesprek/huisbezoek (Tf contact + 3 D) 2
Hemiksem IFG : telefonische contactname (D+3) 7
Niel IFG : bureelgesprek/huisbezoek (Tf contact + 3 D) 2
Rumst IFG : bureelgesprek/huisbezoek (Tf contact + 3 D) 1
How do I properly get them into python?
I have experimented a bit. I converted the txt into a csv and in Pycharm they look exactly the same. But they are not treated the same.
If I read the txt:
data = pandas.read_csv("q658.txt", sep='\t')
print (data)
I get :
Boom IFG : telefonische contactname (D+3) 13
0 Hemiksem IFG : bureelgesprek/huisbezoek (Tf contact + 3 D) 2
1 Hemiksem IFG : telefonische contactname (D+3) 7
2 Niel IFG : bureelgesprek/huisbezoek (Tf contact + 3 D) 2
3 Rumst IFG : bureelgesprek/huisbezoek (Tf contact + 3 D) 1
If I read the csv:
data = pandas.read_csv("q658.csv", sep= '\t')
print (data)
Boom ... 13
Hemiksem IFG : bureelgesprek/huisbezoek (Tf contact + 3 D) ... NaN
Hemiksem IFG : telefonische contactname (D+3) ... NaN
Niel IFG : bureelgesprek/huisbezoek (Tf contact + 3 D) ... NaN
Rumst IFG : bureelgesprek/huisbezoek (Tf contact + 3 D) ... NaN
[4 rows x 3 columns]
However, in both cases, if I set header to zero or none, I get:
ValueError: header must be integer or list of integers
How do I best get it into Python, and how do I get it to treat the first row the same as the others?
data = pandas.read_csv("q658.csv", sep= '\t', header='none')
print (data)
gives:
ValueError: header must be integer or list of integers