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 7605869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:16:32+00:00 2026-05-31T00:16:32+00:00

Im very very new to python, I’m using it here as Im told it’s

  • 0

Im very very new to python, I’m using it here as Im told it’s good for fileIO.

I have a CSV file in the following format. It records the daily activity for my staff.


Date, Name, Project, Manager

01/01/10, Tommy, HyperDyne, Joe Bloggs

01/01/10, Sue, Robot, Joe Bloggs

01/01/10, Mark, HyperDyne, Joe Bloggs

02/01/10, Tommy, SICK,

03/01/10, Tommy, HyperDyne, Joe Bloggs


When an employee is marked as SICK, the manager field is always blank. I want to fill in the Manager field with the previous manager entry for that employee. I want to fill in all the blanks in the csv, and put in NULLS when we cannot say.

In pseudocode-ish:

Forall lines n
if n.Project = "Sick"
  y = 1
  if n-y.name = n.name
      n.manager = n-y.manager
  else y++
  if y > n
      n.manager = null

(could probably wrap that into a for y < n loop perhaps)

This would need to be either edit the input file, or output a new file. I suspect editing the input file would be easier, as people can be sick multiple days in a row.

Would love some advice, its been ages since Ive done procedural programming

  • 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-31T00:16:33+00:00Added an answer on May 31, 2026 at 12:16 am

    You could go through each line of input.csv, read + check it and then write it to output csv.
    While you loop through the lines, keep a record of the previous manager for each person.
    When you encounter a ‘SICK’ row, lookup the previous manager in your records

    Here’s some incpomplete code to illustrate:

    previous_managers = dict()
    for line in csv:
        name = line.name
        project = line.project
        manager = line .manager
    
        if project == 'SICK':
            manager = previous_managers[person] or 'NULL'
        else:
            previous_managers[person] = manager
    
        write(name, project, manager)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new to Python and have a question. Currently I'm using this to
New here. Also I'm (very) new to python and trying to understand the following
I very new to Python, and fairly new to regex. (I have no Perl
I am very new to Python. Not learnt classes yet. Using Python 3.2.2. Tried
I'm very new to Python and multithreaded programming in general. Basically, I have a
I am very new to Python, I need to read numbers from a file
I am very new in Python, and I am really surprised at the following
I am very new to Python and I have been trying to detect missing
Im very new to C programing, but have limited experience with Python, Java, and
I have a problem writing a file with Pickle in Python Here is my

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.