Python Forum
Search Excel File with a list of values
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Search Excel File with a list of values
#5
I was thinking about filtering the dataframe columns using the wordlist. That way, I wouldn't have to create a tuple of all values from the excel. I got 1 filter, the department name down using the below code:

for line in res:
                x, y = line
                wordlist.append(y[0].lower())
                df = dframe[dframe['depName'].str.lower().isin (wordlist)]
What I have now are again the [wordlist] and a filtered df. The next filter, is to match the machine ID to that in CVS. However, in the CSV:

[inline]kvadsun,"te6659,3416652","w/h:1,block b,alqou-3",email:,"p.o282062,dub",[email protected],keep_trct·__223/dustrialds_buildhardware,inv_validCode,cm no.,: c23/d00134,…....,/////////alph,: 01/09/2023,vareg:0575413,sm id,: s-12,vareg,003455795___,nitpr
[/inline]

The 10th value has special character " : " in the machine ID. The current filtered df reads below:

erpNum mch_id depName
488 HO5106 259 Keep_Trct
530 HO5129 267 Keep_Trct
770 HO5290 391 Keep_Trct
975 HO5431 C23/D00134 Keep_Trct
977 HO5432 I23/D00448 Keep_Trct

Sorry I'm not sure how to add a table, but in the above filtered table, the value in mch_id @ 975 doesn't match because of the special characters. So, I wanted to use the above mch_id values as regex pattern to match against the csv. Ideally, I'd like to filter both using the regex, but the above code was a T&E to see if filtering worked. But the next filter is difficult.
Reply


Messages In This Thread
Search Excel File with a list of values - by huzzug - Oct-25-2023, 06:14 PM
RE: Search Excel File with a list of values - by huzzug - Nov-03-2023, 05:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to read a file as binary or hex "string" so that I can do regex search? tatahuft 3 1,038 Dec-19-2024, 11:57 AM
Last Post: snippsat
  Search in a file using regular expressions ADELE80 2 677 Dec-18-2024, 12:29 PM
Last Post: ADELE80
  Assigning cycle values in a list nmancini 3 962 Sep-16-2024, 09:35 PM
Last Post: deanhystad
  docx file to pandas dataframe/excel iitip92 1 2,487 Jun-27-2024, 05:28 AM
Last Post: Pedroski55
  remove duplicates from dicts with list values wardancer84 27 5,578 May-27-2024, 04:54 PM
Last Post: wardancer84
  Python openyxl not updating Excel file MrBean12 1 1,986 Mar-03-2024, 12:16 AM
Last Post: MrBean12
  Copy Paste excel files based on the first letters of the file name Viento 2 1,551 Feb-07-2024, 12:24 PM
Last Post: Viento
  Copying the order of another list with identical values gohanhango 7 2,520 Nov-29-2023, 09:17 PM
Last Post: Pedroski55
  Updating sharepoint excel file odd results cubangt 1 2,040 Nov-03-2023, 05:13 PM
Last Post: noisefloor
  trouble reading string/module from excel as a list popular_dog 0 913 Oct-04-2023, 01:07 PM
Last Post: popular_dog

Forum Jump:

User Panel Messages

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