issue in handling CSV data

Sharan Basappa sharan.basappa at gmail.com
Sun Sep 8 08:41:07 EDT 2019


On Sunday, 8 September 2019 04:56:29 UTC-4, Andrea D'Amore  wrote:
> On Sun, 8 Sep 2019 at 02:19, Sharan Basappa <sharan.basappa at gmail.com> wrote:
>  This is the error:
> > my_data_3 = my_data_2.astype(np.float)
> > could not convert string to float: " "81
> 
> > As you can see, the string "\t"81 is causing the error.
> > It seems to be due to char "\t".
> 
> It is not clear what format do you expect to be in the file.
> You say "it is CSV" so your actual payload seems to be a pair of three
> bytes (a tab and two hex digits in ASCII) per line.
> 
> Can you paste a hexdump of the first three lines of the input file and
> say what you expect to get once the data has been processed?

Andrea,

The issue seems to be presence of tabs along with the numbers in a single string. So, when I try to convert strings to numbers, it fails due to presence of tabs.

Here is the hex dump:

22 61 64 64 72 65 73 73 2c 22 09 22 6c 65 6e 67 
74 68 2c 22 09 22 38 31 2c 22 09 35 63 0d 0a 22 
61 64 64 72 65 73 73 2c 22 09 22 6c 65 6e 67 74 
68 2c 22 09 22 30 34 2c 22 09 31 31 0d 0a 22 61 
64 64 72 65 73 73 2c 22 09 22 6c 65 6e 67 74 68 
2c 22 09 22 65 31 2c 22 09 31 37 0d 0a 22 61 64 
64 72 65 73 73 2c 22 09 22 6c 65 6e 67 74 68 2c 
22 09 22 36 61 2c 22 09 36 63 0d 0a 22 61 64 64 
72 65 73 73 2c 22 09 22 6c 65 6e 67 74 68 2c 22 
09 22 35 33 2c 22 09 36 39 0d 0a 22 61 64 64 72 
65 73 73 2c 22 09 22 6c 65 6e 67 74 68 2c 22 09 
22 39 38 2c 22 09 38 37 0d 0a 22 61 64 64 72 65 
73 73 2c 22 09 22 6c 65 6e 67 74 68 2c 22 09 22 
35 63 2c 22 09 34 62 0d 0a 22 61 64 64 72 65 73 
73 2c 22 09 22 6c 65 6e 67 74 68 2c 22 09 22 32 
38 2c 22 09 33 36 0d 0a 22 61 64 64 72 65 73 73 
2c 22 09 22 6c 65 6e 67 74 68 2c 22 09 22 36 33 
2c 22 09 35 30 0d 0a 22 61 64 64 72 65 73 73 2c 
22 09 22 6c 65 6e 67 74 68 2c 22 09 22 32 34 2c 
22 09 32 31 0d 0a 22 61 64 64 72 65 73 73 2c 22 
09 22 6c 65 6e 67 74 68 2c 22 09 22 64 66 2c 22 
09 39 61 0d 0a 22 61 64 64 72 65 73 73 2c 22 09 
22 6c 65 6e 67 74 68 2c 22 09 22 61 62 2c 22 09 
62 39 0d 0a 22 61 64 64 72 65 73 73 2c 22 09 22 



More information about the Python-list mailing list