Python - Read from multiple files & Regex search pattern in files

preview_player
Показать описание
Friends! I read your questions in comments and emails you send to me. For those which could be useful for others, I post a video. So ASK QUESTIONS !!!

Arshdeep's Question :

I have a python problem to extract words between specified strings from a text file.
The data is like below—-
:20: sguyy IT fun :23B j if d set hkvfg
Gkk jk kgg hu g dat in
Jddgji
Th jjjj WCP 3678654 Commonwealth guujvccbb
I want to extract text between :20: and :23B:

Also, want to extract Trent/ numbers between WCP and Commonwealth

We are going to use regular expression(regex) to find the pattern in file(s).

Feel free to ask your questions in comments section... Do not forget to like this video and subscribe to our channel.
Рекомендации по теме
Комментарии
Автор

Great video. Thanks, helped with some searches on patterns! Look forward to more videos

luc
Автор

Hi Kamal, Nice video. I wanted to ask what if we have several occurrences of search pattern and we want to store all using regrex ?

kamalpreet
Автор

Thank you, this is exactly what I was looking for

Daalen
Автор

Hi Kamal, i just need to search certain list of values/strings across a pandas dataframe and list all the rows maches that particular jobnames along with other columns

harshachimirala
Автор

Hi Kamal,

Thank you so much for this very informative and helpful video.
I have a related question. I'd like to extract words, however, the word I'd like to extract is on a separate line. This means I can not use print.(re.search('word1 (.*?) word2', fin).group(1)).
How to solve a similar problem when the word I'd like to extract is on a separate line?
Your answer would be a lifesaver!

Best Johanna

johannafinnstrom
Автор

Hi Kamal
That's informative.
I have some difficulty
To read the text file and identify specific number and replace and save back in a different text file

Text file contains the following
S No Speed Acceleration Distance
1 120 25 12
2 150 50 20
3 200 35 18

i want to replace the 200 speed with 165 and save in a different text file
I will be very thankful to you if you help me on the above.

Thanks,
Arun

arunsandeep
Автор

Hi,
I have a df column, where the state info is given in parenthesis. EX: [Col Name]: the object is find in 3 st Mauve (TX).
How could I extract the state name given in the parenthesis into a separate column for further analysis. Please help?

janakiyeluripati
Автор

Hi Kamal, Thanks for the video which is very informative.
Can you help with sample program where if line x got match then need to return line x+1

adinarayanapillutla
Автор

Hi, in a directory there are multiple folders. Each folder has sub folders.
How do we print the file names in all these sub folders which follow the file path */src/gen/*. This file path pattern can be present anywhere inside any folder or folder.

soumyaav
Автор

I have an csv, xml, json and text i want to give a single file path for them can you help me

SanjeevKumar-ddsd
Автор

Thanks for this video..how can we run one python file by taking different input text file one by one from a folder and save output for individual file in folder.. please help

vsddkkjjhgrreertyfdserrftyh
Автор

Hi Kamal, thank you very much for the detailed information video. I have one pdf file which contains multiple lines and address and quantity etc. I want to search billing address and extract next address lines XYZ company. It will very helpful if you could help me.
Like "Bill Address"
XYZ company
street, road aa.

bcmanyam
Автор

Hi Kama,
can you help me to validate a html files, whether all the tags are correct or not ?

rewadia
Автор

Could you please help me with the below
I have a file with content as below
Hi :'welcome to python'
'enjoy learning. Bye '

I want to read only the contents specified within single quotes in a file and write it in a another file

suhasinik
Автор

how to make it, but with changes, now how to ask the string that the script will find?

javiersalas
Автор

How to write this code using while loop for print multiple files

it_programming
Автор

How to do this?
User input:
BrancA folder path
BranchB folder path

Output:
Different Funcion Name of BranchB
Full path of File Name in BranchB
LineNo
Ex: void Hello(), xxx/xx/yy/file.c, #7

rizvim
Автор

Hi, I like to know if i want to read a excel spreadsheet, and have all a pattern like this. INV123456 and add all with this pattern. how can it be done. Thanks for your advise. I think your video is easy to understand.

cheonglily
Автор

How about when the number of files is very large, lets say 1 million?

mknarula
Автор

Hi Kamal,

Am trying this with both RegEx and SQLParse libraries.
(1) Read sql file as plain text file
(2) Get the complete sql query for "DELETE" statement. This might be single line or spread across multiple lines.
(3) on this block of text, use either SqlSpars or RegEx to check whether WHERE condition exists
(4) If yes, ignore. If no, PRINT notification with line number

This is one of the rules to check. But am find it hard to read the full query blocks from the sql file. Could you please help

rvandakar