0

I have a set of dates for which I need to load files of. I am unable to parse the value

    for i in range(frst,lst):

        start_evt=datetime.strptime(start_evt_list[i], '%Y_%m_%d_%H_%M_%S')
        end_evt=datetime.strptime(end_evt_list[i], '%Y_%m_%d_%H_%M_%S')

        str_evt = start_evt.strftime('%Y_%m_%d_%H_%M_%S')+'__'+end_evt.strftime('%Y_%m_%d_%H_%M_%S')

        R_disdro_all=np.loadtxt(path_input+'_R_30_sec_'+str_evt+'.csv',delimiter=';') #linewhere issue is

error:

  could not convert string to float: '2016-01-01 20:54:30'

expected value

  str_evt = '2016_01_01_20_54_30__2016_01_01_21_48_00'

name of files to be called (changes as per date)

 'R_30_sec_2016_01_01_20_54_30__2016_01_01_21_48_00.csv'

Since files are saved in above format, I need to call them in that way? Any workaround on that?

edit:

sample of csv

   2016-01-01 21:04:00;0.3073087739822634

   2016-01-01 21:04:30;0.36085429321242296

   2016-01-01 21:05:00;1.6908339772030656

   2016-01-01 21:05:30;8.433402591355255

   2016-01-01 21:06:00;7.455470718196002

   2016-01-01 21:06:30;9.262826859140507

   2016-01-01 21:07:00;4.742752695716012

   2016-01-01 21:07:30;9.360660258092658

   2016-01-01 21:08:00;8.82796654322043

1 Answers1

1

The cause of the error seems to be caused by reading csv in numpy the wrong way.

I guess I can see how your csv is written to see the solution.

A similar error can be found at the link below.

numpy.loadtxt, ValueError: could not convert string to float

joonghyup cha
  • 624
  • 3
  • 12