I have a file with over 2000 lines that I need to parse. I want to make sure I get 100% accurate results, which will then be imported to my MariaDB.
The file looks like this:
line 0: #start#
line 1: 20111211\200000
line 2: n=john|l=smith,131_stree_apt#102_city_state_11111_country,19989989988|17771112222,user%64domain.com,12,21,551|626|23\r
...
line 2156: #end#
so
line 1 is the date time in 24h format
line 2 is the line format:
- n = name
- l = last name
- full address
- phone + cell phone
- total goals
- total passes
- time on ice + time on bench
- penality minutes
I can’t figure out the regular expression. My other idea was to parse each line and then parse each comma, then each pipe, etc., but I think this approach is slow and less accurate then regex. Am I right?
Why don’t you go and try it out?
Don’t let this intimedate you, be bold.
In general, I’d do the following if I were you:
~2000 records is not so much, so the third step might not even be required (in particular if this is a migration that only runs once — so what if it takes 2 minutes?).
BTW: This is general programming advice and does apply to a lot of problems. Don’t optimize prematurely.