0

When using genfromtext() numpy seems to remove the '.' character from the header name. Is there a way to turn this feature off?

file.csv header

column1,column.2

cmd

a = np.genfromtxt(open('file.csv'), delimiter=',', names=True, dtype=None, autostrip=True)

results

> a['column.2']
field named column.2 not found

a['column2'] is however found.

Community
  • 1
  • 1
Matt Stokes
  • 4,618
  • 9
  • 33
  • 56
  • See also: http://stackoverflow.com/q/16020137/1461210, http://stackoverflow.com/q/35234643/1461210 – ali_m Mar 01 '16 at 19:05

1 Answers1

-1

You are trying to open a csv file with np.genfromtxt, I suggest you to use pandas.read_csv(namefile) instead; this would handle headers automatically.

Giovanni
  • 32
  • 1