Python: Convert string (in scientific notation) to float

前端 未结 4 1934
小鲜肉
小鲜肉 2020-12-09 09:42

I\'m trying to import a large .csv file containing text and numbers using genfromtxt in numpy. I\'m only interested in two columns. I have most of the import sorted out wit

4条回答
  •  庸人自扰
    2020-12-09 10:23

     with open( datafile,'r' ) as inData:
         for line in inData:
              j = list( map( float,   filter( None  , [ x for x in line.strip().split(',') ] )) )
    

    Just mentioned generally, as it solves a similar problem that brought me to this page.

提交回复
热议问题