Python Forum
Only getting last record saved...Why
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Only getting last record saved...Why
#5
I have tried to fix the problem. So looked up the os commands and saw the following used. Problem is I can't get the indentation right no matter where I put it...that line is track_name = line[0] here is the new code.

for f in os.listdir(file_dir): 
        file_name, file_ext = os.path.splitext(f)
        f_name = file_name + file_ext
        file_name = file_name.strip()[3:]
        line_counter = 0
        if file_name == Race_date and file_ext == ".jcp":
            with open(f_name, "r") as csv_file:
                csv_reader = csv.reader(csv_file)
                 
                for line in csv_reader:
                     
                                             
 
                 
                     
                    h = {'track' : line[0],
                    'race_number' : line[2], 
                    'todays_surface' : line[6],
                     
                     
                     
 
                 
                        }
 
           				track_name = line[0]
        path_dir:  str= r"C:\guis\daily_racefiles"      
        filename : str =   (track_name + ".csv")
        path_file = os.sep.join([path_dir, filename])
        with open(path_file, 'a') as csv_file:
            d_writer = csv.DictWriter(csv_file, fieldnames = field)
            d_writer.writerow(h)
                 
    my_labeldone= Label( text ="Downloading Complete", fg= "black", font = ("sans_serif" , 16)).place(x=500, y=500    
I am very frustrated. I have been working on this for 6 hours or so.
Reply


Messages In This Thread
Only getting last record saved...Why - by Milfredo - Sep-09-2020, 03:21 AM
RE: Only getting last record saved...Why - by buran - Sep-09-2020, 07:01 AM
RE: Only getting last record saved...Why - by Milfredo - Sep-09-2020, 07:30 AM
RE: Only getting last record saved...Why - by buran - Sep-09-2020, 07:45 AM
RE: Only getting last record saved...Why - by buran - Sep-09-2020, 08:28 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Last record in file doesn't write to newline gonksoup 3 610 Jan-22-2024, 12:56 PM
Last Post: deanhystad
  How do I stream and record at the same time with arducam? traderjoe 0 578 Oct-23-2023, 12:01 AM
Last Post: traderjoe
  Using .pb saved model for object detection hobbyist 2 1,292 Aug-03-2022, 05:55 AM
Last Post: hobbyist
  bytes object saved as .mp4 jttolleson 10 6,229 Feb-25-2022, 02:42 PM
Last Post: jttolleson
  Why can't numpy array be restored to a saved value? pjfarley3 1 1,817 Nov-25-2020, 07:40 AM
Last Post: pjfarley3
  Running scripts and location of saved interpreted user-defined classes and functions leodavinci1990 3 2,691 Aug-25-2020, 03:43 AM
Last Post: micseydel
  how can we record a video file from our program output (moving object) Zhaleh 0 1,898 Aug-03-2020, 02:47 PM
Last Post: Zhaleh
  Get the record number of a dBASE dbf file DarkCoder2020 0 1,864 Jun-16-2020, 05:11 PM
Last Post: DarkCoder2020
  Compare 5 variables in a record with an excel sheet!! SEED 1 1,891 Apr-20-2020, 11:10 PM
Last Post: michael1789
  How to insert record into MySQL using Phython abhay_kala 1 2,372 Dec-06-2019, 04:34 PM
Last Post: abhay_kala

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020