1

I am very much a numbie to python.

DISPLAY should read: surname, Firstname, Day1 ,Day2,Both Days,NoDays

I have 2 txt files. employee.txt has the above information. confpack has 2 lines : 1. going 2. Bonus

employee.txt is like this: *(this is written in each line having surname,firstname,Y, Y Surname,firtname, , Y

  • the Y =going blank space=not going

employees: doe,john,Y, , Smith,Mary, , Y, Candy,Jim,Y,Y,

confpack is like this: (2 lines)

am going
BONUS going

So I have the following code..but having trouble putting it all together I need to bring the 2 files together to display the information. as mentioned above.

index = 0
prev = 0
str = Y[0]
substr = "Y"
while index < len(str):

index = str.find(substr,index)

if index == -1:
    break
prev = index + len(substr)
index += len(substr)
len((str))
with open("confPack.txt", "r") as input_file2:
for line2 in input_file2:

    print(" this is where: ", line2)
  • You should not be using regex to search for for fixed substrings. Regex are for *pattern* matches. If you just search for `Y`, use `target_str.index('Y')` or `'Y' in target_str`. Also you really should use the `csv` module to read CSV data. – Tomalak Jun 29 '20 at 11:13
  • I'm sure that you can get much help. from me or from others, if you succeed in explaining better your requirements. In the first file, how do you name the 4 columns, `firstname`, `surname` and ??? The second file contains only two lines? what is the second file used for? it's not clear to me... If you think that you can improve your question, please [edit] it, thank you – gboffi Jun 29 '20 at 12:09
  • I have edited the post..hope that makes things clearer. I appreciate the help – Nena Carreira Jun 30 '20 at 00:24
  • I'm afraid I still don't understand... If you still need to solve this problem with Python, try to read your post as it was written from someone else and correct the points that are not clear and also the chaotic formatting (insert blank lines and/or indents to get what you want). Finally, to repeat myself for the 3rd time, what is the role of the second file? – gboffi Jun 30 '20 at 15:05
  • Problem solved..thanks for your help anyway. – Nena Carreira Jul 01 '20 at 10:18

0 Answers0