Coding Up — Python Data-Parse Teaching

為自己Coding
·
·
IPFS
·


Yo is here to share with you today that I use a Python suite Parse in my work. I almost didn't see his introductory text on the Internet. I think it's very useful and intuitive, so I want to write a record. Like re (regular expression), it is used to capture the data we want

Github Teaching Links


1. Of course, you must first download this package, I use anaconda to download (open your Anaconda prompt and type the following string)

 pip install parse

2. parse()

As long as you type a {}, it will grab the data you want according to the position of {}, enter the name you want in {}, like {name}, it will help you parse it into a dictionary form ,perfectly worked
a. Warning: parse(a,b) the length of a and b must be the same, otherwise it will not catch
b. Chinese can also play

3. search()

I personally like this function very much, because it is super intuitive, and it does not have the problems that parse() will encounter. You can easily find the corresponding data according to the pattern before and after the data you want, but if you do not add the following pattern, It will only catch one word, such as Age:26, if you type Age:{} it will only catch 2, then there are two ways to solve it, one is to change it to {:d} or add the following pattern , Age:{}, (one more comma), it catches

4. findall()

1. In this way, we can quickly put the data we want into a list, so that we can make a dataframe later
, csv, very easy to use

2. It is very suitable for grabbing html files

5. compile()

If you feel that it is very troublesome to type the data we are looking for every time, as long as you use it, you only need to enter it once and you can always use it on different text(type(str))

Hope it helps you~~

If you have any questions, you can also ask me directly, I'm afraid I can't help you, because I may not, but we can study together, haha


Reference source:

https://pypi.org/project/parse/

CC BY-NC-ND 2.0

Like my work? Don't forget to support and clap, let me know that you are with me on the road of creation. Keep this enthusiasm together!

為自己CodingYO~~ 剛跨入AI人工智慧領域的小小工程師, 熱愛自學, 熱愛分享, 下班後的我想為自己Coding, 積極撰寫教學文, 想將自學的程式知識分享給大家, 不斷追求進步的自己, 希望有一天能回饋社會,幫助需要幫助的人, 如果您有什麼很酷的想法,也覺得我還行,歡迎您找我合作~~ IG: https://www.instagram.com/coding_4_me/
  • Author
  • More

[Takeaways]原力效應 — Part1

[行銷5.0] 人工智慧的緣起

[Aptos學習筆記#8]Move進階使用 - Resource介紹一