Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6208133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:45:20+00:00 2026-05-24T05:45:20+00:00

I have written this code and what I am trying to do here is

  • 0

I have written this code and what I am trying to do here is to write the values generated from this function and another one which are in stored as lists in timeList and
parameterList. I am not exactly supposed to write the values of timeList in the same function I guess. It should probably be done in a separate function. I have already got the timeList in curve.dat file. Now I have to write the parameterList in the same file but not following the values of timeList but on the right side of the timeList. The timeList in curve.dat file is:

0.07
0.06
0.08
0.12
0.11
0.09
0.14
0.05
0.06

The parameterList is:

[0.744527502029805, 1.3466145472841764, 2.8186875392157371, 3.2822440320192392, 7.9272007790523782, 6.0493081375991276, 9.2609232787439613, -611.06135600582172, -399.75236270058838]

Now I should have the contents of curve.dat file as the following:

0.07       0.744527502029805  
0.06       1.3466145472841764  
0.08       2.8186875392157371  
0.12       3.2822440320192392  
0.11       7.9272007790523782  
0.09       6.0493081375991276  
0.14       9.2609232787439613  
0.05       -611.06135600582172  
0.06       -399.75236270058838  

Could someone help with this please. Thank you.

def time(transcriptionFile) :
    with open("transcriptions.txt", "r") as tFile :
        timeList = []
        parameterList = []

        for line in tFile :
            li = line.split()
            if li :
                start_time = (int(li[0]) / 10000000.)
                end_time = (int(li[1]) / 10000000.) 
                duration = ((int(li[1]) -int(li[0]))/10000000.)
                timeList.append(duration) # t(u) values for plotting the bezier curves

                with open("curve.dat", "w") as outFile:
                    outFile.write("\n".join(str(x) for x in timeList))

                poly = poly_coeff(start_time, end_time, duration)

                Newton(poly, 0.42, parameterList) 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:45:20+00:00Added an answer on May 24, 2026 at 5:45 am

    Do not write timeList to the file while inside the for line in tFile loop.
    Notice how many times you are opening and closing the file (very inefficient). Also notice if you open the file in 'w' (write) mode instead of 'a' (append) mode, it overwrites the previous contents…

    Instead, wait (delay gratification!) until you have both timeList and parameterList assembled. Then do

    with open("curve.dat", "w") as outFile:
        for t,p in zip(timeList,parameterList):
            outFile.write('{t}\t{p}\n'.format(t=t,p=p))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a jQuery script (I have never written one before and
I am trying to write a data calculated from this function in a file.
Hopefully this is a really quick one ;) I have written a lexer /
I have written a java annotation that looks like this: @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) // can
I have always written regexes like this <A HREF=([^]*) TARGET=_blank>([^<]*)</A> but I just learned
This is what I have written: if ((lstProperty[i].PropertyIdentifier as string).CompareTo(Name) == 0) Resharper put
I have written a secure TCP server in .NET. This was basically as simple
I have written a Windows service that spawns a separate process. This process creates
I have normally hand written xml like this: <tag><?= $value ?></tag> Having found tools
I have this bit of javascript written with jQuery 1.2.5. It's contained inside the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.