Python Forum
Find (each) element from a list in a file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find (each) element from a list in a file
#1
Greetings!
I want to scan a .csv file, find cells with dates, and create a list of dates.
then I'd like to check the same file and find strings that contain the dates from the list.
I'm going to process the lines later.
Here is the code that does not work Sad
with open('C:/01/Logs_Scan_removed_prt.csv','r') as ftor :
    for el in ftor :
        el.strip()
        el=el.split(",")
        tof = el[4]
        dates.append(el[4])       
    for el in ftor :
        #print(el)    
        for ed in dates :
            print(f" ++ {ed}")
            if ed in el :
                print(f" found Line -> {el}")
Thank you.
Reply


Messages In This Thread
Find (each) element from a list in a file - by tester_V - Nov-15-2022, 05:44 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  element in list detection problem jacksfrustration 5 444 Apr-11-2024, 05:44 PM
Last Post: deanhystad
  list in dicitonary element problem jacksfrustration 3 753 Oct-14-2023, 03:37 PM
Last Post: deanhystad
  Program to find Mode of a list PythonBoy 6 1,168 Sep-12-2023, 09:31 AM
Last Post: PythonBoy
  FileNotFoundError: [WinError 2] The system cannot find the file specified NewBiee 2 1,623 Jul-31-2023, 11:42 AM
Last Post: deanhystad
  find random numbers that are = to the first 2 number of a list. Frankduc 23 3,288 Apr-05-2023, 07:36 PM
Last Post: Frankduc
  Cannot find py credentials file standenman 5 1,699 Feb-25-2023, 08:30 PM
Last Post: Jeff900
  selenium can't find a file in my desk ? SouAmego22 0 759 Feb-14-2023, 03:21 PM
Last Post: SouAmego22
  compare and find the nearest element ? mr_gentle_sausage 4 1,093 Jan-15-2023, 07:11 AM
Last Post: DPaul
  Сheck if an element from a list is in another list that contains a namedtuple elnk 8 1,885 Oct-26-2022, 04:03 PM
Last Post: deanhystad
  [SOLVED] [Beautifulsoup] Find if element exists, and edit/append? Winfried 2 4,353 Sep-03-2022, 10:14 PM
Last Post: Winfried

Forum Jump:

User Panel Messages

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