numpy.genfromtxt does not read data correctly when there is '#' hashtag

852 views Asked by At

This is my fixed width file

SNO,NAME,AGE
1abc@-+  18
2def_=   22
3ghi${   22
2jkl%]   22
1mn#o    50
3pqr()   14
5stu?    18
6!`$%^&*(20

when i try to read it from numpy.genfromtxt, i get

+---+--------+---+
|SNO|    NAME|AGE|
+---+--------+---+
|  1|abc@-+  | 18|
|  2|def_=   | 22|
|  2|ghi${   | 22|
|  2|jkl%]   | 22|
|  1|      mn|   |
|  3|pqr()   | 14|
|  5|stu?    | 18|
|  6|!`$%^&*(| 20|
+---+--------+---+

So it works fine for every other special character except '#' In '#' case, it takes data before # and replaces subsequent data as blank

I have tried using dtype as 'U' for unicode, but the same type of behaviour is coming

I am using the code

data = numpy.genfromtxt('abc.fw',dtype='str',skip_header=1,delimiter=(1,8,2))

0

There are 0 answers