Dear all,

i have data coming in file named time.csv and i wanted to convert the file in format conv_file format . How could i do it python

Use the csv module (standard lib) discussion here.

Using csv does not help, because there isn't a single comma in the input.

The first row in the output is:
11 hour, 38 min, 47 sec.

So the seconds are: 11*60*60+38*60+47= 4197

How is 44700 calculated? What is that?

Something like this:

with open("conv.csv","w") as fo:
    with open("time.csv") as f:
        for c,line in enumerate(f):
            if c==0: continue
            fs=map(str.strip,line.split("."))
            ts=int(fs[0])*60*60+int(fs[1])*60+int(fs[2])
            fo.write(",".join((fs[0],fs[1],fs[2],str(ts)))+"\n")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.