Dec-22-2019, 10:02 AM
(Dec-21-2019, 05:16 PM)Gribouillis Wrote: If you don't mind using someone else's code, there is a module in pypi named 'text2digits' under the MIT licence that does the number conversion
>>> from text2digits import text2digits >>> td2 = text2digits.Text2Digits() >>> td2.convert("I'm twenty five years old") "I'm 25 years old" >>> td2.convert("seventy two") '72'Considering that you are a beginner in python, it would probably be a good idea to use this code instead of rewriting your own. You will probably meet many other issues before the project is complete.
This is a fantastic module. The problem of last statement has been solved.
Then, I would like to use real syntax file in Etabs for conversion.
However, there is a new problem
![Confused Confused](https://python-forum.io/images/smilies/confused.png)
In my example, I know that there are 3 sentences and the position of the keywords so that I can extract the word and convert it.
The code I have used on the above is that I already know the file just had 3 statements so I append them into a list and assign a name for them.
But in Etabs, for example the storey statement, I don't know how many storeys are in the model previously so I can't use the code on the above.
So, how can I ensure that all the statements are extracted from the file?