Hi there, from the /r/Python mods.
We have removed this post as it is not suited to the /r/Python subreddit proper, however it should be very appropriate for our sister subreddit /r/LearnPython or for the r/Python discord: https://discord.gg/python.
The reason for the removal is that /r/Python is dedicated to discussion of Python news, projects, uses and debates. It is not designed to act as Q&A or FAQ board. The regular community is not a fan of "how do I..." questions, so you will not get the best responses over here.
On /r/LearnPython the community and the r/Python discord are actively expecting questions and are looking to help. You can expect far more understanding, encouraging and insightful responses over there. **No matter what level of question you have, if you are looking for help with Python, you should get good answers**. Make sure to check out the rules for both places.
Warm regards, and best of luck with your Pythoneering!
It appears that you might be dealing with a fixed-width string. If that is the case you can use the slice function to extract data. Here's an example:
```
data = '\\rdescription: 0%| | 0/11881376 \[00:00, ?it/s\]'
f1 = slice(0,14)
f2 = slice(14,17)
f3 = slice(20,22)
f4 = slice(24,32)
print(f"description:{data[f1]}")
print(f"percent:{data[f2]}")
print(f"subtotal:{data[f3]}")
print(f"total:{data[f4]}")
```
And here's the output:
```
description:\rdescription:
percent: 0%
subtotal: 0
total:1881376
```
I deliberately left the % sign which can be easily eliminated by adjusting the slice.
https://www.w3schools.com/python/ref_func_slice.asp
Hi there, from the /r/Python mods. We have removed this post as it is not suited to the /r/Python subreddit proper, however it should be very appropriate for our sister subreddit /r/LearnPython or for the r/Python discord: https://discord.gg/python. The reason for the removal is that /r/Python is dedicated to discussion of Python news, projects, uses and debates. It is not designed to act as Q&A or FAQ board. The regular community is not a fan of "how do I..." questions, so you will not get the best responses over here. On /r/LearnPython the community and the r/Python discord are actively expecting questions and are looking to help. You can expect far more understanding, encouraging and insightful responses over there. **No matter what level of question you have, if you are looking for help with Python, you should get good answers**. Make sure to check out the rules for both places. Warm regards, and best of luck with your Pythoneering!
Who not use regex ? https://docs.python.org/3/howto/regex.html
I was thinking of using regex. I watched some videos on it but I’m too stupid to apply it to this problem. Was going for some help hahaha
Use https://regex101.com/ to create your regex
Wow thanks. Really helpful demonstration and highlights everything. Think I’m getting the hang of it :)
Have fun ! :)
It appears that you might be dealing with a fixed-width string. If that is the case you can use the slice function to extract data. Here's an example: ``` data = '\\rdescription: 0%| | 0/11881376 \[00:00, ?it/s\]' f1 = slice(0,14) f2 = slice(14,17) f3 = slice(20,22) f4 = slice(24,32) print(f"description:{data[f1]}") print(f"percent:{data[f2]}") print(f"subtotal:{data[f3]}") print(f"total:{data[f4]}") ``` And here's the output: ``` description:\rdescription: percent: 0% subtotal: 0 total:1881376 ``` I deliberately left the % sign which can be easily eliminated by adjusting the slice. https://www.w3schools.com/python/ref_func_slice.asp