I need to do the following things开发者_如何学Python for a text file..and insert the seeked words to a excel please give me some tips:
Seek the letter sequence anywhere in the file "stg-" take the first two characters from where it is searched ... eg if the sentence has abc-stg-c5-sfdsdf then it should take c5 and this c5 should insert in the first column first row of the excel file.
My first impression is that the search is best conducted by using a Regex.
You don't say if you have an open instance of Excel (i.e. you can do the insert using Excel automation), or if you want to write it directly into an Excel compatible file - in which case you may find it simplest to write a comma-delimited file.
Does this help?
精彩评论